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 ...
随机推荐
- HDU [P1704] Rank
传递闭包裸题 但是本题的Floyd一定要优化,不然会T cpp #include <iostream> #include <cstdio> #include <cstri ...
- 香甜的黄油 Sweet Butter
原题链接:https://www.luogu.org/problem/show?pid=1828#sub 经典的最短路问题. 各位不要被题目条件迷惑了,牧场想象成点,道路想象成边,奶牛所在的位置想象成 ...
- 剑指offer得意之作——顺时针打印矩阵
题目: 输入一个矩阵,按照从外向里以顺时针的顺序依次打印出每一个数字,例如,如果输入如下矩阵: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 则依次打印出数字1,2,3 ...
- pip install 提示"no previously-included directories found matching"及"no previously-included files matching found anywhere in distribution",且偶发无法关联安装 PyPI 库的故障
环境描述: Python 2.7.5 CentOS-7.2 报错现象: (1).在虚拟环境下运行 pip install 命令安装 PyPI 第三方库,出现类似如下告警. Running setu ...
- Windows Server 2012开启多人远程
首先在Server Roles中选择Remote Desktop Services,然后在Role Services中安装Remote Desktop Session Host 安装完成后需要重启机器 ...
- 【vim】插件管理及代码智能提示与补全环境的配置
1. 引言 可以使用脚本/插件来给vim添加各种神奇的功能,从更换颜色主题.到代码智能提示,甚至项目管理.无数开发者通过开源社区贡献自己开发的插件,使得vim有可能变得无比强大.这儿http://vi ...
- WPF: 深入理解 Weak Event 模型
在之前写的一篇文章(XAML: 自定义控件中事件处理的最佳实践)中,我们曾提到了在 .NET 中如果事件没有反注册,将会引起内存泄露.这主要是因为当事件源会对事件监听者产生一个强引用,导致事件监听者无 ...
- Go解析写死的json
func TestAliAfpAdapter_AskAd_Banner(t *testing.T) { apiData := getApiData() apiData.ApiInfo.ApiPosit ...
- 移动端页面点击a标签会有半透明的阴影或红色边框的bug
好久没有更新了,今天来一发 ^_^ 最近在写移动端页面,测试时发现一个a标签的bug:无论是iOS端还是Android端都存在,当点击a标签,会有一个矩形的透明的阴影闪一下(不同的浏览器阴影的颜色还不 ...
- [工具]Microsoft To-Do,简约还是简陋?
1. 简介 微软收购奇妙清单后,由奇妙清单的原班人马打造了一个全新的待办事项应用,就叫"To-Do"(简单粗暴,好像新浪微博直接就叫"微博"的感觉).这个应该刚 ...