ZCMU训练赛-A(模拟)
A - Applications
https://vjudge.net/contest/174208#overview
Recently, the ACM/ICPC team of Marjar Universitydecided 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:
- (1) The problems in a set, called MaoMao Selection, will be counted as 2.5 pts for a problem.
- (2) The problems from Old Surgeon Contest, will be counted as 1.5 pts for a problem.
There is no problem in MaoMao Selectionfrom Old Surgeon Contest.
- (3) Besides the problem from MaoMao Selection and Old Surgeon Contest, if the problem's id is a prime, then it will be counted as 1 pts.
- (4) If a solved problem doesn't meet above three condition, then it will be counted as 0.3 pts.
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:
- The member of a team will be counted as 36 pts if the team won first prize in the competition.
- The member of a team will be counted as 27 pts if the team won second prize in the competition.
- The member of a team will be counted as 18 pts if the team won third prize in the competition.
- Otherwise, 0 pts will be counted.
3. We all know that some websites held problem solving contest regularly, such as JapanJam,ZacaiForces and so on. The registered member ofJapanJam 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:
Here 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!
Input
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 inMarjar 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 inJapanJam.
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:
- The problems' id in MaoMao Selection, Old Surgeon Contest and applicant's solving list are distinct, and all of them have 4 digits (such as 1010).
- All names don't contain spaces, and length of each name is less than 30.
- All ratings are non-negative integers and less than 3500.
<h4< dd="">Output
For each test case, output M lines, means that Mapplicants 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.
<h4< dd="">Sample Input
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
<h4< dd="">Sample Output
FScarlet 60.000 IamMM 44.300 A 36.000
1 #include <iostream> 2 #include<cstdio> 3 #include<cmath> 4 #include<algorithm> 5 #include<queue> 6 #include<cstring> 7 using namespace std; 8 const int N = 505; 9 const double eps = 1e-5; 10 11 int maomao[N],old[N]; 12 bool is[10000]; 13 int n,m,r,s,teamnum; 14 struct node1 15 { 16 char t_name[31]; 17 int prize; 18 }team[N]; 19 struct node2 20 { 21 char name[31],team[31],sex[31]; 22 double score; 23 int p,c; 24 int solved[1001],ranks[1001]; 25 }app[N]; 26 27 void getprm() 28 { 29 int i,j; 30 memset(is,0,sizeof(is)); 31 for(i = 4;i <= 10000;i += 2) 32 is[i] = 1; 33 for(i = 3;i <= 10000;i += 2) 34 { 35 if(is[i] == 0) 36 { 37 for(j = i + i;j <= 10000;j += i) 38 is[j] = 1; 39 } 40 } 41 } 42 43 int ismaomao(int x) 44 { 45 int i; 46 for(i = 0;i < r;i ++) 47 if(maomao[i] == x) 48 return 1; 49 return 0; 50 } 51 52 int isold(int x) 53 { 54 int i; 55 for(i = 0;i < s;i ++) 56 if(old[i] == x) 57 return 1; 58 return 0; 59 } 60 61 int isprime(int x) 62 { 63 int i; 64 for(i = 2;i * i <= x;i ++) 65 if(x % i == 0) 66 return 0; 67 return 1; 68 } 69 70 int cmp(struct node2 a,struct node2 b) 71 { 72 if(fabs(a.score - b.score) < eps) 73 return strcmp(a.name,b.name) < 0; 74 else 75 return a.score > b.score; 76 } 77 78 int teamprize(int id) 79 { 80 int i; 81 for(i = 0;i < teamnum;i ++) 82 { 83 if(strcmp(app[id].team,team[i].t_name) == 0) 84 return team[i].prize; 85 } 86 return 0; 87 } 88 89 int main() 90 { 91 getprm(); 92 int t; 93 int i,j; 94 scanf("%d",&t); 95 while(t --) 96 { 97 scanf("%d%d",&n,&m); 98 scanf("%d",&r); 99 for(i = 0;i < r;i ++) 100 scanf("%d",&maomao[i]); 101 sort(maomao,maomao + r); 102 scanf("%d",&s); 103 for(i = 0;i < s;i ++) 104 scanf("%d",&old[i]); 105 sort(old,old + s); 106 scanf("%d",&teamnum); 107 for(i = 0;i < teamnum;i ++) 108 { 109 scanf("%s%d",team[i].t_name,&team[i].prize); 110 } 111 for(i = 0;i < n;i ++) 112 { 113 scanf("%s%s%s%d%d",app[i].name,app[i].team,app[i].sex,&app[i].p,&app[i].c); 114 if(app[i].sex[0] == 'F') 115 app[i].score = 33; 116 else 117 app[i].score = 0; 118 for(j = 0;j < app[i].p;j ++) 119 { 120 scanf("%d",&app[i].solved[j]); 121 if(ismaomao(app[i].solved[j])) 122 app[i].score = app[i].score + 2.5; 123 else 124 { 125 if(isold(app[i].solved[j])) 126 app[i].score = app[i].score + 1.5; 127 else 128 { 129 if(isprime(app[i].solved[j])) 130 app[i].score = app[i].score + 1; 131 else 132 app[i].score = app[i].score + 0.3; 133 } 134 } 135 } 136 for(j = 0;j < app[i].c;j ++) 137 scanf("%d",&app[i].ranks[j]); 138 switch(teamprize(i)) 139 { 140 case 1:app[i].score = app[i].score + 36; 141 break; 142 case 2:app[i].score = app[i].score + 27; 143 break; 144 case 3:app[i].score = app[i].score + 18; 145 break; 146 default: 147 break; 148 } 149 sort(app[i].ranks,app[i].ranks + app[i].c); 150 if(app[i].c >= 3) 151 { 152 int tmp = app[i].ranks[app[i].c - 3]; 153 double tp = (tmp - 1200) / 100.0; 154 tp = tp * 1.5; 155 if(tp > 0) 156 app[i].score = app[i].score + tp; 157 } 158 } 159 sort(app,app + n,cmp); 160 for(i = 0;i < m;i ++) 161 printf("%s %.3f\n",app[i].name,app[i].score); 162 } 163 return 0; 164 }