题意:
第一行给出一个数字,代表样例的个数
第二行给出两个数,代表人数和输出排名的前几个人
第三四行分别给出MaoMao Selection和Surgeon Contest的题目数量与题号
第五行给出拿到前三等奖的数目,接下来给出每个获奖的队伍和获得的排名
最后给出每个人的信息,包括人名,队名,性别,OJ里的做题数,参加比赛的数目
然后给出题号与比赛的得分
而每个人的得分计算是这样:
首先是做的题所得的分:
1.在MaoMao Selection做的题得2.5分
2.在Surgeon Contest做的题得1.5分
3.如果不在这两个地方做的题并且题号为素数,得1分
4.否则0.3分
如果所在的队伍得奖了:一等奖36分,二等27,三等18
如果是女的:得到33分
如果参加过比赛,则取排第三的分数,计算公式Pts = max(0, (r - 1200) / 100) * 1.5为得分,如果小于3次比赛则不算
思路;
这道题目很复杂,主要是要求计算的东西太多,理解题意后就好做了。这里用到了map用来联系获奖的队伍与申请队伍。
#include<iostream>
#include<stdio.h>
#include<string>
#include<cstring>
#include<algorithm>
#include<map>
using namespace std;
struct pre
{
string name;
double pts;
}p[1055];
double a[10000];
int b[1000];
int isprime(int x)///求素数
{
if(x==1) return 0;
if(x==2) return 1;
for(int i=2;i*i<=x;i++)
if(x%i==0) return 0;
return 1;
}
int cmp1(int a,int b)
{
return a>b;
}
int cmp2(pre a,pre b)
{
//if(a.pts==b.pts) return strcmp(a.name,b.name)
return a.pts>b.pts;
}
int main()
{
int t,n,m;
map<string,int>mp;
// memset(zz,0,sizeof(zz));
// init();
scanf("%d",&t);
while(t--)
{
mp.clear();
memset(a,0,sizeof(a));
scanf("%d %d",&n,&m);
string s1,s2,s3;
int temp,y;
scanf("%d",&temp);
for(int i=0;i<temp;i++)
{
scanf("%d",&y);
a[y]=2.5;
}
scanf("%d",&temp);
for(int i=0;i<temp;i++)
{
scanf("%d",&y);
//cout<<y<<endl;
a[y]=1.5;
}
scanf("%d",&temp);
for(int i=0;i<temp;i++)
{
cin>>s1;
scanf("%d",&y);
if(y==1) y=36;
else if(y==2) y=27;
else if(y==3) y=18;
else y=0;
mp[s1]+=y;
}
int kk;
for(int i=0;i<n;i++)
{
cin>>s1>>s2>>s3;
p[i].name=s1;
p[i].pts=mp[s2];
if(s3=="F") p[i].pts+=33;
// cout<<p[i].pts<<endl;
scanf("%d%d",&temp,&kk);
for(int j=0;j<temp;j++)
{
scanf("%d",&y);//cout<<a[y]<<endl;
if(a[y]>0) p[i].pts+=a[y];//
else if(isprime(y)) p[i].pts+=1;//cout<<y<<" "<<flag[y]<<endl;
else p[i].pts+=0.3;
//cout<<p[i].pts<<endl;
}
//cout<<123<<"*************************************************************"<<endl;
memset(b,0,sizeof(b));
//scanf("%d",&temp);cout<<temp<<endl;
for(int j=0;j<kk;j++)
scanf("%d",&b[j]);
sort(b,b+kk,cmp1);
p[i].pts+=max(0.0, (b[2] - 1200)*1.0 / 100) * 1.5 ;
// cout<<p[i].pts<<endl;
}
sort(p,p+n,cmp2);
for(int i=0;i<m;i++)
{
cout<<p[i].name;
printf(" %.3f\n",p[i].pts);
}
}
return 0;
}