#include <iostream>#include <map>#include <cstring>#include <string>#include <cmath>#include <iomanip>#include <algorithm>using namespace std;int maomaoselection[505];int olddot[505];int maomaonum,oldnum;int cflevel[1050];class competition{public:string team;int ranker; };class people{public:string name;string team;char sex;double score;};competition teamer[505];people mass[505];bool cmpcf(int a,int b){return a>b;}double Max(double a,double b){if(a>b)return a;elsereturn b;}int isprime(int n){ for (int i=2;i<=sqrt(n);i++) { if (n%i==0) return 0; } return 1;}double jamcal(int r){return Max(0,((r-1200)/100.0)*1.5);}bool ismaomao(int id){for(int i=0;i<maomaonum;i++){if(id==maomaoselection[i])return 1;}return 0;}bool isolddot(int id){for(int i=0;i<oldnum;i++){if(id==olddot[i])return 1;}return 0;}bool cmp(people a,people b){return a.score>b.score;}int main(){int testcase;cin>>testcase;while(testcase--){int totalperson,rankperson,tmp,jamaverage;string tmp2;memset(maomaoselection,0,sizeof(maomaoselection));memset(olddot,0,sizeof(olddot));map<string,int> team;int competitionnum;cin>>totalperson>>rankperson>>maomaonum;for(int i=0;i<maomaonum;i++){cin>>maomaoselection[i];}cin>>oldnum;for(int j=0;j<oldnum;j++){cin>>olddot[j];}cin>>competitionnum;for(int i=0;i<competitionnum;i++){cin>>teamer[i].team>>teamer[i].ranker;}for(int i=0;i<totalperson;i++){memset(cflevel,0,sizeof(cflevel));string teamname;int avgscore,solvequestion,cfnum;double res=0;cin>>mass[i].name>>teamname>>mass[i].sex>>solvequestion>>cfnum;mass[i].team=teamname;if(mass[i].sex=='F')res+=33;for(int k=0;k<solvequestion;k++){cin>>tmp;if(ismaomao(tmp)==1){res+=2.5;}else if(isolddot(tmp)==1){res+=1.5;}else if(isprime(tmp)==1){res+=1;}else{res+=0.3;}}for(int t=0;t<competitionnum;t++){if(teamname==teamer[t].team){if(teamer[t].ranker==1){res+=36;}else if(teamer[t].ranker==2){res+=27;}else if(teamer[t].ranker==3){res+=18;}}}for(int p=0;p<cfnum;p++){cin>>cflevel[p];} sort(cflevel,cflevel+cfnum,cmpcf);avgscore=cflevel[2]; res+=jamcal(avgscore);mass[i].score=res;}sort(mass,mass+totalperson,cmp);for(int a=0;a<rankperson;a++){cout<<mass[a].name<<" "<<setiosflags(ios::fixed)<<setprecision(3)<<mass[a].score<<endl;}}return 0;}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)