Aizu-0033 Ball
2015-10-30 16:03
381 查看
/************************************************ * Author :somniloquy * Created Time :2015/10/30 14:32:53 ************************************************/ #include <cstdio> #include <algorithm> #include <iostream> #include <cstring> using namespace std; int t, n; int num[10]; int sign[10]; void dfs(int now, int next) { if(next < 10 && num[now] < num[next]) { sign[next] = 1; dfs(next, next + 1); } else if(next < 10 && num[now] >= num[next]) dfs(now, next + 1); } int main(void) { scanf("%d", & t); while(t --) { for(int i = 0; i < 10; i ++) scanf("%d", & num[i]); bool flag; for(int i = 0; i < 10; i ++) { flag = true; memset(sign, 0, sizeof(sign)); sign[i] = 1; dfs(i, i + 1); int max_temp = -1; for(int i = 0; i < 10; i ++) { if(!sign[i]) { if(max_temp < num[i]) max_temp = num[i]; else { flag = false; break; } } } if(flag) { printf("YES\n"); break; } } if(!flag) printf("NO\n"); } return 0; }
题目:
输入测试组数t。
之后每组直接输入10个数。
问这10个数能不能分成两堆单调严格递增的序列。(按顺序出栈)
输出YES or NO。
题解:
思想还是太死板..
枚举每一种元素为首的情况,用dfs取后面满比当前值大的数,取到用sign标记。判断另一堆剩余的数是否满足题意。
相关文章推荐
- ORA-00054 资源正忙, 但指定以 NOWAIT 方式获取资源, 或者超时失效"的快速解决方法
- 如何签名apk,并让baidu地图正常显示
- Fail to connect to camera service的几种原因和解决方法
- 解决Linux报错:httpd: Could not reliably determine the server's fully qualified domain name, using localh
- raise语句
- Juniper Open contrail 虚拟网络互通
- Aizu-0118 Property Distribution
- AirPlay简介
- kaili 2.0 虚拟机修改ip
- codeforces 19E Fairy 树链剖分
- kaili 2.0 开启ssh远程
- [转][Err] 1452 - Cannot add or update a child row: a foreign key constraint fail
- ITelephony.aidl
- 解决 org.hibernate.HibernateException: Could not obtain transaction-synchronized Session for cu
- Mail Servers
- Weblogic 的安装 创建domain 启停服务
- 小议:Domain User无法远程登录Computer
- Hibernate4运行报错Could not obtain transaction-synchronized Session for current thread
- MongoDB分片集群启动过程中Failed to connect to 127.0.0.1:27017错误解决办法
- Daily Scrum 10.30