Crash CodeForces - 417B
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.
Example
2
0 1
1 1
YES
4
0 1
1 2
1 1
0 2
NO
4
0 1
1 1
0 1
0 2
YES 其实题目不难,理解后就是一个水题。
如果代码不合理输出NO反则输出YES
本菜鸟定义了一个结构体 x对应的是所交的代码数,y对应的是学号。
(代码合理的条件:所交的代码数必须逐渐增加,必须从0开始,
后面的对应学号的所交的代码数不能大于(0+1)
表达能力不是很好。
下面放代码你们应该就可以很好的理解了。
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
struct node
{
int x,y;
}qu[];
int ans[];
int main() {
int n;
while(scanf("%d",&n)!=EOF){
for (int i= ;i< ;i++) ans[i]=-;
memset(vis,,sizeof(vis));
int flag=;
for (int i= ;i<n ;i++){
scanf("%d%d",&qu[i].x,&qu[i].y);
if (ans[qu[i].y]+>=qu[i].x){
if (qu[i].x==ans[qu[i].y]+) ans[qu[i].y]=qu[i].x;
}else {
flag=;
}
}
if (flag) printf("YES\n");
else printf("NO\n");
}
return ;
}
Crash CodeForces - 417B的更多相关文章
- CodeForces - 417B (思维题)
Crash Time Limit: 1000MS Memory Limit: 262144KB 64bit IO Format: %I64d & %I64u Submit Status ...
- 【codeforces 750D】New Year and Fireworks
time limit per test2.5 seconds memory limit per test256 megabytes inputstandard input outputstandard ...
- 【腾讯Bugly干货分享】聊聊苹果的Bug - iOS 10 nano_free Crash
本文来自于腾讯Bugly公众号(weixinBugly),未经作者同意,请勿转载,原文地址:https://mp.weixin.qq.com/s/hnwj24xqrtOhcjEt_TaQ9w 作者:张 ...
- iOS 10 开发适配系列 之 权限Crash问题
升级 iOS 10 之后目测坑还是挺多的,记录一下吧,看看到时候会不会成为一个系列. 直入正题吧 今天用一个项目小小练下手,发现调用相机,崩了.试试看调用相册,又特么崩了.然后看到控制台输出了以下信息 ...
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- BZOJ 2154: Crash的数字表格 [莫比乌斯反演]
2154: Crash的数字表格 Time Limit: 20 Sec Memory Limit: 259 MBSubmit: 2924 Solved: 1091[Submit][Status][ ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
随机推荐
- BZOJ 2073: [POI2004]PRZ [DP 状压]
传送门 水题不解释 这道题的主要目的在于记录一个枚举子集的技巧 #include <iostream> #include <cstdio> #include <cstri ...
- demo说明
访问http://192.168.90.63:30111/face_mark/, 会看到上图的界面. 下面简单说下如何使用这个demo. 一.选择选择同一个人不同角度的五张图. 选中了五张图片.此时任 ...
- 📟 Character Liquid Crystal Display Control (English)
A replica CLCD module control. Initiated on May 5, 2012 Updated on Feb 21, 2017 Copyright 2012-2017 ...
- BCDEdit命令添加WinPE启动项
bcdedit /create {ffffffff-8d96-11de-8e71-ffffffffffff} /d "系统维护" /device bcdedit /create ...
- CEF小白人系列1-认识CEF
手头上有个项目需要做浏览器的相关功能,评估了几个嵌入式方案最后选定CEF作为开发基础. 在入坑新技术的时候第一选择是去官网学习,这是一个非常好的习惯. CEF官网(请科学上网) https://bit ...
- Mock摆脱后端拖拉(借鉴官网)(一)
mock是一个模拟数据生成器,旨在帮助前端独立于后端进行开发,帮助编写单元测试.mock有如下功能 根据数据模板生成模板数据 模拟ajax请求,生成请求数据 基于html模板生成模拟数据 下载安装 n ...
- 【项目记录】-路灯监测 gmap.net
需求 2016年5月,客户要求在地图上显示路灯及数据,分析数据生成报表,以便查看分析路灯情况. 选型 国外项目就不考虑国内的地图了,开始想使用google的web地图,考虑到地图上标记物过多影响性能及 ...
- JAVA浮点数计算精度损失底层原理与解决方案
浮点数会有精度损失这个在上大学的时候就已经被告知,但是至今完全没有想明白其中的原由,老师讲的时候也是一笔带过的,自己也没有好好琢磨.终于在工作的时候碰到了,于是google了一番. 问题: 对两个do ...
- hdu1061(2015-N1):1.快速幂;2.找规律
1.快速幂 原理:求a的b次方,将b转化为二进制数,该二进制位第i位的权是2^(i-1), 例如 11的二进制是1011 11 = 2³×1 + 2²×0 + 2¹×1 + 2º×1 因此,我们将a¹ ...
- APP性能测试(CPU)
获取数据 :adb shell dumpsys cpuinfo | grep packagename result = os.popen("adb shell dumpsys cpuinfo ...