首页 > 代码库 > 未完成代码存档 codevs 2905

未完成代码存档 codevs 2905

#include <algorithm>#include <cstring>#include <cstdio>#include <map>#define Mod 13831using namespace std;map<int,int>q;int n;struct Node{    int point;    char Name[101];    int Hash;}Team[7];bool cmp(Node a,Node b){    return a.point>b.point;}int main(){    scanf("%d",&n);    if(n==1) {printf("King");return 0;}    char ch=getchar();    while(n--)    {        char str[101],Match[1010];        int maxn=-0x7fffffff;        for(int k=1;k<=4;k++)        {            gets(str);            int x=0;            int len=strlen(str);            for(int i=0;i<len;i++) x=(x*10+str[i])%Mod;            Team[k].Hash=x;            strcpy(Team[k].Name,str);            Team[k].point=0;            q[x]=k;        }        for(int k=1;k<=6;k++)        {            gets(Match);            int i=0,len=strlen(Match),x1=0,x2=0,y1=0,y2=0;            while(Match[i]!= ) x1=(x1*10+Match[i++])%Mod;            i++;            while(Match[i]!=:) x2=x2*10+(int)Match[i++]-48;            i++;            while(Match[i]!= ) y2=y2*10+(int)Match[i++]-48;            i++;            for(int k=i;k<len;k++) y1=(y1*10+Match[k])%Mod;            if(x2>y2) Team[q[x1]].point+=3;            else if(x2==y2) Team[q[x1]].point++,Team[q[y1]].point++;            else if(x2<y2) Team[q[y1]].point+=3;        }        sort(Team+1,Team+1+4,cmp);        printf("%s\n",Team[1].Name);        for(int i=1;i<=4;++i) Team[i].point=0,Team[i].Hash=0;    }    return 0;}

 

未完成代码存档 codevs 2905