codeforces 417B Crash
2015-12-08 21:02
169 查看
Description
During the “Russian Code Cup” programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x(x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Sample Input
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
题意:在比赛过程,每个选手可以提交若干次代码,现在有n次提交,每次提交有两个参数,x表示该选手提交的第x+1份不同代码(即前面提交的代码中有x种和当前份不同),k表示第k位选手提交的代码。问说这n次提交是否有误。
During the “Russian Code Cup” programming competition, the testing system stores all sent solutions for each participant. We know that many participants use random numbers in their programs and are often sent several solutions with the same source code to check.
Each participant is identified by some unique positive integer k, and each sent solution A is characterized by two numbers: x — the number of different solutions that are sent before the first solution identical to A, and k — the number of the participant, who is the author of the solution. Consequently, all identical solutions have the same x.
It is known that the data in the testing system are stored in the chronological order, that is, if the testing system has a solution with number x(x > 0) of the participant with number k, then the testing system has a solution with number x - 1 of the same participant stored somewhere before.
During the competition the checking system crashed, but then the data of the submissions of all participants have been restored. Now the jury wants to verify that the recovered data is in chronological order. Help the jury to do so.
Input
The first line of the input contains an integer n (1 ≤ n ≤ 105) — the number of solutions. Each of the following n lines contains two integers separated by space x and k (0 ≤ x ≤ 105; 1 ≤ k ≤ 105) — the number of previous unique solutions and the identifier of the participant.
Output
A single line of the output should contain «YES» if the data is in chronological order, and «NO» otherwise.
Sample Input
Input
2
0 1
1 1
Output
YES
Input
4
0 1
1 2
1 1
0 2
Output
NO
Input
4
0 1
1 1
0 1
0 2
Output
YES
题意:在比赛过程,每个选手可以提交若干次代码,现在有n次提交,每次提交有两个参数,x表示该选手提交的第x+1份不同代码(即前面提交的代码中有x种和当前份不同),k表示第k位选手提交的代码。问说这n次提交是否有误。
[code]#include <iostream> #include <cstdio> #include <cstring> #include <cmath> using namespace std; int a[100100]; int main() { int n,x,k,flag=1; cin>>n; memset(a,0,sizeof(a)); for(int i=1; i<=n; i++) { cin>>x>>k; if(x>a[k]) { flag=0; } else if(x==a[k]) a[k]++; } if(flag==0) cout<<"NO"<<endl; else cout<<"YES"<<endl; return 0; }
相关文章推荐
- Jquery 中DOM对象操作
- iOS面试考察点(大总结)待整理的答案
- 有趣的数
- 【Android游戏开发之三】详细剖析 SurfaceView ! Callback以及SurfaceHolder!!
- zookeeper/dubbo使用记录
- gd支持freetype扩展
- 什么叫穷举法?
- 【Android游戏开发之二】剖析游戏开发用view还是surfaceView ?!
- POJ 2195:Going Home
- Android笔记-Android启动之Android Framework启动
- 运维入门--- -bash: /usr/local/maven/apache-maven-3.2.3/bin/mvn: Permission denied
- 【shell】我的wait为什么不能用
- 【比较】类图和对象图
- phpstorm中实时将SCSS编译为CSS
- JavaEE_Mybatis_SpringMVC_整合开发_Controller的返回值
- JAVA兼容低版本JDK的正确编译方式
- Linux与windows之间-文件传输工具RZSZ
- mongodb操作
- android oom 全解析
- 《大话操作系统——扎实project实践派》(8.2)(除了指令集.完)