Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:!!!求数据!!!In Reply To:!!!求数据!!! Posted by:maoyoulong at 2011-09-04 18:27:52 本人新手,哪位大侠能不能帮我看看错在哪儿啊!!先行谢过! #include<string> #include<stdlib.h> #include<iostream> using namespace std; struct node { char name[10]; bool solve[10]; int num[10],time[10],last,solved; }; node team[20]; int cmp(const void *m1,const void *m2) { node *team1=(node*)m1; node *team2=(node*)m2; if(team1->solved==team2->solved) { if(team1->last-team2->last) return (team1->last>team2->last)?1:-1; return strcmp(team1->name,team2->name)>0?1:-1; } return (team1->solved<team2->solved)?1:-1; } int main() { char n[10],yn[10]; int cas,teams,problem,submit,pro[2000],t[2000],s[2000],rank,i,j; scanf("%d",&cas); while(cas--) { scanf("%d",&teams); for(i=0;i<teams;i++) { scanf("%s",team[i].name); memset(team[i].num,0,sizeof(team[i].num)); memset(team[i].solve,false,sizeof(team[i].solve)); for(j=0;j<10;j++) team[i].time[j]=100000; team[i].last=team[i].solved=0; } scanf("%d %d",&problem,&submit); for(i=0;i<submit;i++) { scanf("%d%d%s%s",&pro[i],&t[i],yn,n); pro[i]--, j=0; while(strcmp(n,team[j].name)) j++; s[i]=j; if(!strcmp(yn,"Yes")) { if(!team[j].solve[pro[i]]) team[j].solve[pro[i]]=true, team[j].solved++; if(t[i]<team[j].time[pro[i]]) team[j].time[pro[i]]=t[i]; } } for(i=0;i<submit;i++) if(t[i]<team[s[i]].time[pro[i]]) team[s[i]].num[pro[i]]++; for(i=0;i<teams;i++) for(j=0;j<problem;j++) if(team[i].solve[j]) team[i].last+=team[i].time[j]+20*team[i].num[j]; qsort(team,teams,sizeof(team[0]),cmp); rank=1; for(i=0;i<teams;i++) { printf("%2d. %-8s% 2d% 5d\n", rank, team[i].name,team[i].solved,team[i].last); if(i) if( (team[i+1].solved-team[i].solved) || (team[i+1].last-team[i].last) ) rank=i+2; } puts(""); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator