A. Is it rated?
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Is it rated?
Here it is. The Ultimate Question of Competitive Programming, Codeforces, and Everything. And you are here to answer it.
Another Codeforces round has been conducted. No two participants have the same number of points. For each participant, from the top to the bottom of the standings, their rating before and after the round is known.
It’s known that if at least one participant’s rating has changed, then the round was rated for sure.
It’s also known that if the round was rated and a participant with lower rating took a better place in the standings than a participant with higher rating, then at least one round participant’s rating has changed.
In this problem, you should not make any other assumptions about the rating system.
Determine if the current round is rated, unrated, or it’s impossible to determine whether it is rated of not.
Input
The first line contains a single integer n (2 ≤ n ≤ 1000) — the number of round participants.
Each of the next n lines contains two integers ai and bi (1 ≤ ai, bi ≤ 4126) — the rating of the i-th participant before and after the round, respectively. The participants are listed in order from the top to the bottom of the standings.
Output
If the round is rated for sure, print “rated”. If the round is unrated for sure, print “unrated”. If it’s impossible to determine whether the round is rated or not, print “maybe”.
Examples
input
6
3060 3060
2194 2194
2876 2903
2624 2624
3007 2991
2884 2884
output
rated
input
4
1500 1500
1300 1300
1200 1200
1400 1400
output
unrated
input
5
3123 3123
2777 2777
2246 2246
2246 2246
1699 1699
output
maybe
Note
In the first example, the ratings of the participants in the third and fifth places have changed, therefore, the round was rated.
In the second example, no one’s rating has changed, but the participant in the second place has lower rating than the participant in the fourth place. Therefore, if the round was rated, someone’s rating would’ve changed for sure.
In the third example, no one’s rating has changed, and the participants took places in non-increasing order of their rating. Therefore, it’s impossible to determine whether the round is rated or not.
题意:给出n个人的rank的变化,问正常比赛时rated还是unrated还是maybe。
题解:如果有rank的变化 那么肯定是rated的。否则看变化后的rank是否递减。递减为maybe,否则为unrated。
代码:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6;
int x[N];
int y[N];
int main()
{
int n;
cin>>n;
bool flag=false;
for(int i=1;i<=n;i++)
{
cin>>x[i]>>y[i];
if(x[i]!=y[i])
flag=true;
}
if(flag)
cout<<"rated"<<endl;
else
{
for(int i=2;i<=n;i++)
{
if(y[i]>y[i-1])
{
cout<<"unrated"<<endl;
return 0;
}
}
cout<<"maybe"<<endl;
}
}
B. T-Shirt Hunt
time limit per test2 seconds
memory limit per test256 megabytes
inputstandard input
outputstandard output
Not so long ago the Codecraft-17 contest was held on Codeforces. The top 25 participants, and additionally random 25 participants out of those who got into top 500, will receive a Codeforces T-shirt.
Unfortunately, you didn’t manage to get into top 25, but you got into top 500, taking place p.
Now the elimination round of 8VC Venture Cup 2017 is being held. It has been announced that the Codecraft-17 T-shirt winners will be chosen as follows. Let s be the number of points of the winner of the elimination round of 8VC Venture Cup 2017. Then the following pseudocode will be executed:
i := (s div 50) mod 475
repeat 25 times:
i := (i * 96 + 42) mod 475
print (26 + i)
Here “div” is the integer division operator, “mod” is the modulo (the remainder of division) operator.
As the result of pseudocode execution, 25 integers between 26 and 500, inclusive, will be printed. These will be the numbers of places of the participants who get the Codecraft-17 T-shirts. It is guaranteed that the 25 printed integers will be pairwise distinct for any value of s.
You’re in the lead of the elimination round of 8VC Venture Cup 2017, having x points. You believe that having at least y points in the current round will be enough for victory.
To change your final score, you can make any number of successful and unsuccessful hacks. A successful hack brings you 100 points, an unsuccessful one takes 50 points from you. It’s difficult to do successful hacks, though.
You want to win the current round and, at the same time, ensure getting a Codecraft-17 T-shirt. What is the smallest number of successful hacks you have to do to achieve that?
Input
The only line contains three integers p, x and y (26 ≤ p ≤ 500; 1 ≤ y ≤ x ≤ 20000) — your place in Codecraft-17, your current score in the elimination round of 8VC Venture Cup 2017, and the smallest number of points you consider sufficient for winning the current round.
Output
Output a single integer — the smallest number of successful hacks you have to do in order to both win the elimination round of 8VC Venture Cup 2017 and ensure getting a Codecraft-17 T-shirt.
It’s guaranteed that your goal is achievable for any valid input data.
Examples
input
239 10880 9889
output
0
input
26 7258 6123
output
2
input
493 8000 8000
output
24
input
101 6800 6500
output
0
input
329 19913 19900
output
8
Note
In the first example, there is no need to do any hacks since 10880 points already bring the T-shirt to the 239-th place of Codecraft-17 (that is, you). In this case, according to the pseudocode, the T-shirts will be given to the participants at the following places:
475 422 84 411 453 210 157 294 146 188 420 367 29 356 398 155 102 239 91 133 365 312 449 301 343
In the second example, you have to do two successful and one unsuccessful hack to make your score equal to 7408.
In the third example, you need to do as many as 24 successful hacks to make your score equal to 10400.
In the fourth example, it’s sufficient to do 6 unsuccessful hacks (and no successful ones) to make your score equal to 6500, which is just enough for winning the current round and also getting the T-shirt.
题意:
题解:没想到什么好的解法。就暴力bfs了。
代码:
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6;
int vis[N];
int a,b,c;
struct node
{
int x,id;
}r,w;
queue<node>q;
set<int>s,f;
void solve(int x)
{
s.clear();
int k=(x/50)%475;
int i=25;
while(i--)
{
k=(k*96+42)%475;
s.insert(k+26);
}
}
int bfs(int x,int id)
{
r.id=id;
r.x=x;
vis[r.x]=1;
q.push(r);
while(!q.empty())
{
w=q.front();
q.pop();
solve(w.x);
if(s.find(a)!=s.end())
{
f.insert(w.id);
continue;
}
for(int i=1;i<=2;i++)
{
if(i==1)
{
r.x=w.x-50;
r.id=w.id;
}
if(i==2)
{
r.x=w.x+100;
r.id=w.id+1;
}
if(vis[r.x]==0&&r.x>=c)
{
q.push(r);
vis[r.x]=1;
}
}
}
return *f.begin();
}
int main()
{
int t;
scanf("%d%d%d",&a,&b,&c);
printf("%d\n",bfs(b,0));
}