lightoj 1374 Confusion in the Problemset
2016-01-14 21:49
381 查看
题目就是说有n页纸,有n个页码,由于存在某些问题导致页码和平时的不一样,这里每页的页码指的是这页前面或者后面还有多少页,问给定的这些页码是否可以排列出来满足上面条件的序列。主意的是页码的范围是<=10^6,n <= 10000。
ps:开始想错了,一位需要将大于n或者小于0的数进行hash,结果wa了三发没懂为啥,,,太蠢了,题目没懂
点击打开题目链接
ps:开始想错了,一位需要将大于n或者小于0的数进行hash,结果wa了三发没懂为啥,,,太蠢了,题目没懂
点击打开题目链接
/***************************************** Author :Crazy_AC(JamesQi) Time :2015 File Name : *****************************************/ // #pragma comment(linker, "/STACK:1024000000,1024000000") #include <iostream> #include <algorithm> #include <iomanip> #include <sstream> #include <string> #include <stack> #include <queue> #include <deque> #include <vector> #include <map> #include <set> #include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <climits> using namespace std; #define MEM(x,y) memset(x, y,sizeof x) #define pk push_back typedef long long LL; typedef unsigned long long ULL; typedef pair<int,int> ii; const double eps = 1e-10; const int inf = 1 << 30; const int INF = 0x3f3f3f3f; const int MOD = 1e9 + 7; const int maxn = 10010; int A[maxn]; int t,icase = 0; int main() { // freopen("in.txt","r",stdin); // freopen("out.txt","w",stdout); int n; scanf("%d",&t); while(t--){ scanf("%d",&n); memset(A, 0,sizeof A); int x; for (int i = 1;i <= n;++i){ scanf("%d",&x); if (x > n || x < 0) continue; A[x] += 1; } bool flag = true; for (int i = 1;i <= n;++i){ int first = i - 1;//指示前面有first页 int second = n - i;//指示后面有second页 if (A[first] > 0){ A[first]--; }else if (A[second] > 0){ A[second]--; } else{ flag = false; break; } } printf("Case %d: ", ++icase); if (flag) printf("yes\n"); else printf("no\n"); } return 0; }
相关文章推荐
- 详细整理:UITableView优化技巧
- mysql 数据库死锁原因及解决办法
- 【codeforces 111C】 Petya and Spiders
- JS之浏览器对象
- 第二天,tranform ,图片浏览器,帧动画代码(我很勤劳的0.0)
- RecyclerView使用详解(三)
- Java Swing JTable 表格【15:组合列表框作为表格元素】
- 详解Runtime运行时机制
- android之获取屏幕宽度、控件宽度
- elasticsearch评分进阶
- 关于SYP'BLOG,关于Problem&Solutions
- C#一探究竟——枚举
- YARN日志聚合相关参数配置
- 2015.01.15 学前端 搞论文提交
- 【bzoj2241】【sdoi2011】【打地鼠】【暴力】
- namespace
- android中layout属性介绍
- Android IntentService
- wget 下载百度云jdk
- mysql 管理