ZOJ - 3705 A - Applications

来源:互联网 发布:ubuntu 关闭swap 编辑:程序博客网 时间:2024/05/16 12:51
Applications

Time Limit: 2 Seconds      Memory Limit: 65536 KB

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:

  • (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 Selection from 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 JapanJamZacaiForces 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.5

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 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:

  • The problems' id in MaoMao SelectionOld 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.

Output

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.

Sample Input

15 33 1001 1002 10034 1004 1005 1006 10073MagicGirl!!! 3Sister's_noise 2NexusHD+NexusHD 1Edward EKaDiYaKanWen M 5 31001 1003 1005 1007 10091800 1800 1800FScarlet MagicGirl!!! F 3 51004 1005 10071300 1400 1500 1600 1700A NexusHD+NexusHD M 0 0B None F 0 0IamMM Sister's_noise M 15 11001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 10153000

Sample Output

FScarlet 60.000IamMM 44.300

A 36.000

max只能比较相同类型!max只能比较相同类型!max只能比较相同类型!
题意:教练要根据以下规则给申请者得分来筛选人数
1、(1)做MaoMao题集里的题,每做一道加2.5分;
(2)做Old Surgeon题集里的题,每做一道加1.5分;
(3)做的题既不是MaoMao,又不是Old Surgeon,题号若是质素,加1分;
(4)以上条件均不满足,每做一题加0.3分
2、根据申请人所属队伍在ACM/ICPC比赛中获得的奖项加分
(1)一等奖加36分
(2)二等奖加27分
(3)三等奖加18分
(4)其他,不加分
3、根据在JapanJam的排名加分
公式为:max(0,(r-1200)/100)*1.5;(r是第三大的排名)
4、如果是女孩加33分
Input
T:测试数据
N:申请人数 M:教练要的人数
R:MaoMao的题数 id:MaoMao题目的id
S:Old Surgeon的题数 id:Old Surgeon题目的id
Q:参加ACM/ICPC的队伍数
teamname:队伍名 prize:队伍获得的名次
以下n部分
name teamname sex P:题数 C:参加JapanJam的次数
P个题目id
C场比赛的排名
Output
排名前M个人的名字和得分,每人占一行。
#include <iostream>#include <cstdio>#include <cstring>#include <algorithm>#include <string>#include <cmath>#include <iomanip>using namespace std;struct PrizeInfo{char team[31];int degree;};struct AppInfo{char name[31];double score;};bool cmp1(int a,int b){return a>b;}bool cmp2(AppInfo a1,AppInfo a2){if(a1.score>a2.score)return true;return false;}double Find_team(char team[], PrizeInfo pinfo[], int Size){for(int i=0;i<Size;i++){if(strcmp(team,pinfo[i].team)==0){if(pinfo[i].degree==1)return 36;if(pinfo[i].degree==2)return 27;if(pinfo[i].degree==3)return 18;return 0;}}return 0;}bool Find_id(int Id, int Id_list[], int Size){for(int i=0;i<Size;i++)if(Id==Id_list[i])return true;return false;}bool isPrime(int x){for(int i=2;i*i<=x;i++)if(x%i==0)return false;return true;}int main(){int T;int n,m;int R, MaoMao_id[512];int S, Old_id[512];int Q;PrizeInfo pinfo[512];AppInfo appinfo[512];char team[31];char sex[2];int P, C;int Id;int Rate[1024];cin>>T;while(T--){cin>>n>>m;cin>>R;for(int i=0; i<R; i++)cin>>MaoMao_id[i];cin>>S;for(int i=0; i<S; i++)cin>>Old_id[i];cin>>Q;for(int i=0; i<Q; i++)cin>>pinfo[i].team>>pinfo[i].degree;for(int i=0; i<n; i++){cin>>appinfo[i].name>>team>>sex>>P>>C;//boy+0 girl+33appinfo[i].score=sex[0]=='M'?0:33;//Prizeappinfo[i].score+=Find_team(team,pinfo,Q);//MaoMao+2.5 Old_Surgeon+1.5 Prime+1 so_on+0.3for(int j=0; j<P; j++){cin>>Id;if(Find_id(Id,MaoMao_id,R))appinfo[i].score+=2.5;else if(Find_id(Id, Old_id,S))appinfo[i].score+=1.5;else if(isPrime(Id))appinfo[i].score+=1;elseappinfo[i].score+=0.3;}//JapanJam the third highest:Pts = max(0, (r - 1200) / 100) * 1.5for(int j=0;j<C;j++)cin>>Rate[j];if(C>=3){sort(Rate,Rate+C,cmp1);appinfo[i].score+=max(0.0,(Rate[2]-1200.0)/100.0)*1.5;}}sort(appinfo,appinfo+n,cmp2);for(int i=0;i<m;i++)cout<<appinfo[i].name<<" "<<fixed<<setprecision(3)<<appinfo[i].score<<endl;}return 0;}



0 0
原创粉丝点击