列表

详情


NC219802. Codeforces

描述

Codeforces is a website that hosts competitive programming contests. It is maintained by a group of competitive programmers from ITMO University. Since 2013, Codeforces claims to surpass Topcoder in terms of active contestants. As of 2018, it has over 600,000 registered users. Codeforces along with other similar websites are used by top sport programmers and by other programmers interested in furthering their career. Codeforces is recommended by many universities. According to Daniel Sleator, professor of Computer Science at Carnegie Mellon University, competitive programming is valuable in computer science education, because competitors learn to adapt classic algorithms to new problems, thereby improving their understanding of algorithmic concepts.
In codeforces contestants are divided into ranks based on their ratings:
≥3000
Legendary Grandmaster
2400 - 2999
Grandmaster
2100 - 2399
Master
1900 - 2099
Candidate Master
1600 - 1899
Expert
1400 - 1599
Specialist
1200 - 1399
Pupil    
0 - 1199
Newbie
After a contest, the rating of the contestant will change. In this problem, you are given a contestant's rating before and after the contest. You need to answer whether the title has changed. If it has changed, please output the original and changed title.

输入描述

The first line contains an integer  — the number of test cases, each test case contains two integers  and  representing contestant's rating before and after the contest.

输出描述

If the title has changed, please output in the form of “ to ”, otherwise output “No”.

示例1

输入:

3
1145 1419
1981 0
3000 4000

输出:

Newbie to Specialist
Candidate Master to Newbie
No

原站题解

上次编辑到这里,代码来自缓存 点击恢复默认模板

Python3(3.9) 解法, 执行用时: 20ms, 内存消耗: 2824K, 提交时间: 2021-03-22 09:44:05

def dw(x):
    if x>=3000:
        return 'Legendary Grandmaster'
    elif x>=2400:
        return 'Grandmaster'
    elif x>=2100:
        return 'Master'
    elif x>=1900:
        return 'Candidate Master'
    elif x>=1600:
        return 'Expert'
    elif x>=1400:
        return 'Specialist'
    elif x>=1200:
        return 'Pupil'
    else:return 'Newbie'
for _ in range(int(input())):
    a,b=map(int,input().split())
    if dw(a)==dw(b):
        print('No')
    else:
        print(dw(a),'to',dw(b))

C++(clang++11) 解法, 执行用时: 3ms, 内存消耗: 396K, 提交时间: 2021-03-25 20:53:35

#include<bits/stdc++.h>
using namespace std;
string s;
string fun(int n){
	if(n>=3000)return "Legendary Grandmaster";
	if(n>=2400)return "Grandmaster";
	if(n>=2100)return "Master";
	if(n>=1900)return "Candidate Master";
	if(n>=1600)return "Expert";
	if(n>=1400)return "Specialist";
	if(n>=1200)return "Pupil";
	return "Newbie";
}
int main(){
	int t;
	int a,b;
	cin>>t;
	while(t--){
		cin>>a>>b;
		if(fun(a)!=fun(b)){
			cout<<fun(a)<<" to "<<fun(b)<<endl;
		}else{
			cout<<"No"<<endl;
		}
	}
}

上一题