Start: Jun, 26, 2019 08:30:00
2019年度暑期短学期第一天
End: Jun, 26, 2019 11:30:00
Time elapsed:
Time remaining:

Problem_ID: I
Result: Accepted
Time: 6ms
Memory: 3804kB
Author: 2018212212189
In contest: 1273

#include<iostream>
#include <cstdio>
#include <cstring>
#include<string>
#include <algorithm>
using namespace std;
struct TEAM
{
    char name[50];
    int rank;
} team[505];

struct MAN
{
    char name[30],team[30];
    char sex[3];
    double score;
    int pro,rush;
    int p[505],r[505];
} man[505];
 
int mao[505],sur[505],k_mao,k_sur;
 
int prime(int x)
{
    int i;
    for(i = 2; i*i<=x; i++)
        if(x%i==0)
            return 0;
    return 1;
}
 
double problem(int x)
{
    int i;
    for(i = 0; i<k_mao; i++)
    {
        if(x == mao[i])
            return 2.5;
    }
    for(i = 0; i<k_sur; i++)
    {
        if(x == sur[i])
            return 1.5;
    }
    if(prime(x))
        return 1;
    return 0.3;
}
 
int cmp_rank(TEAM x,TEAM y)
{
    return x.rank<y.rank;
}
 
double big(double a,double b)
{
    return a>b?a:b;
}
 
int cmp_score(MAN x,MAN y)
{
    return x.score>y.score;
}
 
int cmp_r(double a,double b)
{
    return a>b;
}
int t,man_num,team_num,m,i,j,k,xx;
double ss,r[1005];
int main()
{
    cin>>t;
    while(t--)
    {
        cin>>man_num>>m;
        cin>>k_mao;
        for(i = 0; i<k_mao; i++)
            cin>>mao[i];
        cin>>k_sur;
        for(i = 0; i<k_sur; i++)
            cin>>sur[i];
        cin>>team_num;
        for(i = 0; i<team_num; i++)
            scanf("%s%d",team[i].name,&team[i].rank);
        for(i = 0; i<man_num; i++)
        {
            man[i].score = 0;
            scanf("%s%s%s%d%d",man[i].name,man[i].team,man[i].sex,&man[i].pro,&man[i].rush);
            for(j = 0; j<man[i].pro; j++)
            {
                scanf("%d",&xx);
                man[i].score+=problem(xx);
            }
            sort(team,team+team_num,cmp_rank);
            for(j = 0; j<team_num; j++)
            {
                if(!strcmp(man[i].team,team[j].name))
                {
                    if(team[j].rank==1)
                        man[i].score+=36;
                    else if(team[j].rank==2)
                        man[i].score+=27;
                    else if(team[j].rank==3)
                        man[i].score+=18;
                }
            }
            memset(r,0,sizeof(r));
            for(j = 0; j<man[i].rush; j++)
            {
                scanf("%lf",&r[j]);
            }
            sort(r,r+man[i].rush,cmp_r);
            if(man[i].rush>=3)
                man[i].score+=big(0,((r[2]-1200.0)/100)*1.5);
            if(!strcmp(man[i].sex,"F"))
                man[i].score+=33;
        }
        sort(man,man+man_num,cmp_score);
        for(i = 0; i<m; i++)
        {
            printf("%s %.3lf\n",man[i].name,man[i].score);
        }
    }
    return 0;
}