Recently, the ACM/ICPC team of Marjar University decided to choose some new members from freshmen to take part in the ACM/ICPC competitions of the next season. As a traditional elite university in ACM/ICPC, there is no doubt that application forms will fill up the mailbox. To constitute some powerful teams, coaches of the ACM/ICPC team decided to use a system to score all applicants, the rules are described as below. Please note that the score of an applicant is measured by pts, which is short for "points".
1. Of course, the number of solved ACM/ICPC problems of a applicant is important. Proudly, Marjar University have a best online judge system called Marjar Online Judge System V2.0, and in short, MOJ. All solved problems in MOJ of a applicant will be scored under these rules:
2. Competitions also show the strength of an applicant. Marjar University holds the ACM/ICPC competition of whole school once a year. To get some pts from the competition, an applicant should fulfill rules as below:
3. We all know that some websites held problem solving contest regularly, such as JapanJam, ZacaiForces and so on. The registered member of JapanJam will have a rating after each contest held by it. Coaches thinks that the third highest rating in JapanJam of an applicant is good to show his/her ability, so the scoring formula is:
Pts = max(0, (r - 1200) / 100) * 1.5Here r is the third highest rating in JapanJam of an applicant.
4. And most importantly - if the applicant is a girl, then the score will be added by 33 pts.
The system is so complicated that it becomes a huge problem for coaches when calculating the score of all applicants. Please help coaches to choose the best M applicants!
There are multiple test cases.
The first line of input is an integer T (1 ≤T ≤ 10), indicating the number of test cases.
For each test case, first line contains two integers N (1 ≤N ≤ 500) - the number of applicants and M (1 ≤M ≤ N) - the number of members coaches want to choose.
The following line contains an integer R followed by R (0 ≤R ≤ 500) numbers, indicating the id of R problems in MaoMao Selection.
And then the following line contains an integer S (0 ≤S ≤ 500) followed by S numbers, indicating the id of S problems from Old Surgeon Contest.
The following line contains an integer Q (0 ≤Q ≤ 500) - There are Q teams took part in Marjar University's competition.
Following Q lines, each line contains a string - team name and one integer - prize the team get. More specifically, 1 means first prize, 2 means second prize, 3 means third prize, and 0 means no prize.
In the end of each test case, there are N parts. In each part, first line contains two strings - the applicant's name and his/her team name in Marjar University's competition, a char sex - M for male, F for female and two integers P (0 ≤P ≤ 1000) - the number of problem the applicant solved, C (0 ≤C ≤ 1000) - the number of competitions the applicant have taken part in JapanJam.
The following line contains P integers, indicating the id of the solved problems of this applicant.
And, the following line contains C integers, means the rating for C competitions the applicant have taken part in.
We promise:
For each test case, output M lines, means that M applicants and their scores. Please output these informations by sorting scores in descending order. If two applicants have the same rating, then sort their names in alphabet order. The score should be rounded to 3 decimal points.
1 5 3 3 1001 1002 1003 4 1004 1005 1006 1007 3 MagicGirl!!! 3 Sister's_noise 2 NexusHD+NexusHD 1 Edward EKaDiYaKanWen M 5 3 1001 1003 1005 1007 1009 1800 1800 1800 FScarlet MagicGirl!!! F 3 5 1004 1005 1007 1300 1400 1500 1600 1700 A NexusHD+NexusHD M 0 0 B None F 0 0 IamMM Sister's_noise M 15 1 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 3000
FScarlet 60.000 IamMM 44.300 A 36.000
解题思路:毅力题,该题没有太难的算法,不要什么特殊的写法,考的都是C或C++基础。只是,题目比较长,英语不好的同学会很郁闷。另外就是要求比较多,要有耐心,还要细心,不然就容易出乱子。
#include<cstdio> #include<iostream> #include<cstring> #include<string> #include<algorithm> #include<set> using namespace std; struct node { string name; double score; } student[505]; //学生信息 bool cmp(node a,node b) { //信息排序,分数,名次 if(a.score==b.score) return a.name<b.name; return a.score>b.score; } int prim[10000]; void prime() { //求素数 int i,j; memset(prim,0,sizeof(prim)); for(i=2; i<=5000; i++) { for(j=i+i; j<10000; j+=i) prim[j]=1; } } int main() { int n,m; int i,j; string str; int r,s,q,p,c; int x; int t; int a[1005]; prime(); cin>>t; while(t--) { //t组测试数据 set<int>mms; set<int>osc; set<string> team[4]; cin>>n>>m; cin>>r; for(i=0; i<r; i++) { //mms里面的题号 cin>>x; mms.insert(x); } cin>>s; for(i=0; i<s; i++) { //osc里面的题号 cin>>x; osc.insert(x); } scanf("%d",&q); for(i=0; i<q; i++) { cin>>str; cin>>x; if(x<=3) team[x].insert(str); //前三等奖的组 } for(i=0; i<n; i++) { //n个学生的信息 cin>>student[i].name; student[i].score=0; cin>>str; if(team[1].count(str))student[i].score+=36; //队伍一等奖 else if(team[2].count(str))student[i].score+=27; else if(team[3].count(str))student[i].score+=18; cin>>str; if(str[0]=='F')student[i].score+=33; //女生 cin>>p>>c; for(j=0; j<p; j++) { //p个题目 cin>>x; if(mms.count(x))student[i].score+=2.5; else if(osc.count(x))student[i].score+=1.5; else if(!prim[x])student[i].score+=1; else student[i].score+=0.3; } for(j=0; j<c; j++) //积分赛 cin>>a[j]; sort(a,a+c); if(c>=3&&a[c-3]>1200)student[i].score+=(double)(a[c-3]-1200)/100*1.5; //易错点,一定要注意精度 } sort(student,student+n,cmp); for(i=0; i<m; i++) { cout<<student[i].name<<" "; printf("%.3lf\n",student[i].score); } } return 0; }