1075 PAT Judge (25)
Grandma's mind is really thin! Oh
Sb=1 submit success at least once, that is, a submission score >=0;
Sc[i] =-1, user this question has not been submitted. Not once;
Sc[i] = 0, the user has submitted the problem. Have you scored yet? May or may not have ...
1#include <cstdio>2#include <cstring>3#include <vector>4#include <algorithm>5 using namespacestd;6 7 structstu{8 intID;9 intsc[6];Ten intscore; One intrank; A intAC; - intsb; - }; the BOOLCMP (stu A,stu b) { - if(A.score!=b.score)returnA.score>B.score; - Else if(A.AC!=B.AC)returnA.ac>B.ac; - Else + returna.id<b.id; - } +Stu user[10001]; A intfg[10001]; at - intMain () - { -Memset (FG,0,sizeof(FG)); - intn,k,m; -scanf"%d%d%d",&n,&k,&m); in intex[6]; - for(intI=1; i<=k;i++){ toscanf"%d", ex+i); + } - for(intI=0; i<m;i++){ the intId,pid,sco; *scanf"%d%d%d",&id,&pid,&SCO); $ if(fg[id]==0){Panax NotoginsengFg[id] =1; -User[id].id =ID; theUser[id].ac =0; +User[id].score =0; AUSER[ID].SB =0; the for(intj=1; j<=k;j++){ +USER[ID].SC[J] =-1; - } $ if(sco<0) $User[id].sc[pid] =0; - Else -{User[id].sc[pid] = SCO; USER[ID].SB =1;} the } - Else{Wuyi if(user[id].sc[pid]==-1&& sco<0) theUser[id].sc[pid] =0; - Else if(Sco >=User[id].sc[pid]) { Wu{User[id].sc[pid] = SCO; USER[ID].SB =1;} - } About } $ } - -Vector<stu>SV; - for(intI=1; i<=n;i++){ A for(intj=1; j<=k;j++){ + if(user[i].sc[j]>=0) theUser[i].score + =User[i].sc[j]; - if(ex[j]==User[i].sc[j]) $User[i].ac + =1; the } the if(USER[I].SB = =1 ) the Sv.push_back (User[i]); the } - in sort (Sv.begin (), Sv.end (), CMP); theRv:0].rank =1; the for(intI=1; I<sv.size (); i++){ About if(sv[i].score<sv[i-1].score) theSv[i].rank = i+1; the Else theSv[i].rank = sv[i-1].rank; + } - the for(intj=0; J<sv.size (); j + +){Bayiprintf"%d%05d%d", Sv[j].rank,sv[j].id,sv[j].score); the for(ints=1; s<=k;s++){ the if(sv[j].sc[s]>=0) -printf"%d", Sv[j].sc[s]); - Else theprintf" -"); the } theprintf"\ n"); the } - return 0; the}
1075 PAT Judge (25)