标签:
姥姥的心思真够细的! 呵呵
sb=1 submit成功过至少一次,即某次提交得分>=0;
sc[i] = -1 ,用户这道题没有提交过。一次也没有;
sc[i] = 0 ,用户这道题提交过。是否得分了呢? 可能也可能没有。。。
1 #include <cstdio> 2 #include <cstring> 3 #include <vector> 4 #include <algorithm> 5 using namespace std; 6 7 struct stu{ 8 int id; 9 int sc[6]; 10 int score; 11 int rank; 12 int ac; 13 int sb; 14 }; 15 bool cmp(stu a,stu b){ 16 if(a.score!=b.score) return a.score>b.score; 17 else if(a.ac!=b.ac) return a.ac>b.ac; 18 else 19 return a.id<b.id; 20 } 21 stu user[10001]; 22 int fg[10001]; 23 24 int main() 25 { 26 memset(fg,0,sizeof(fg)); 27 int n,k,m; 28 scanf("%d%d%d",&n,&k,&m); 29 int ex[6]; 30 for(int i=1;i<=k;i++){ 31 scanf("%d",ex+i); 32 } 33 for(int i=0;i<m;i++){ 34 int id,pid,sco; 35 scanf("%d%d%d",&id,&pid,&sco); 36 if(fg[id]==0){ 37 fg[id] = 1; 38 user[id].id = id; 39 user[id].ac = 0; 40 user[id].score = 0; 41 user[id].sb = 0; 42 for(int j=1;j<=k;j++){ 43 user[id].sc[j] = -1; 44 } 45 if(sco<0) 46 user[id].sc[pid] = 0; 47 else 48 {user[id].sc[pid] = sco; user[id].sb = 1;} 49 } 50 else{ 51 if(user[id].sc[pid]==-1 && sco<0) 52 user[id].sc[pid] = 0; 53 else if(sco >= user[id].sc[pid]){ 54 {user[id].sc[pid] = sco; user[id].sb = 1;} 55 } 56 } 57 } 58 59 vector<stu> sv; 60 for(int i=1;i<=n;i++){ 61 for(int j=1;j<=k;j++){ 62 if(user[i].sc[j]>=0) 63 user[i].score += user[i].sc[j]; 64 if(ex[j]==user[i].sc[j]) 65 user[i].ac += 1; 66 } 67 if(user[i].sb ==1 ) 68 sv.push_back(user[i]); 69 } 70 71 sort(sv.begin(),sv.end(),cmp); 72 sv[0].rank = 1; 73 for(int i=1;i<sv.size();i++){ 74 if(sv[i].score<sv[i-1].score) 75 sv[i].rank = i+1; 76 else 77 sv[i].rank = sv[i-1].rank; 78 } 79 80 for(int j=0;j<sv.size();j++){ 81 printf("%d %05d %d",sv[j].rank,sv[j].id,sv[j].score); 82 for(int s=1;s<=k;s++){ 83 if(sv[j].sc[s]>=0) 84 printf(" %d",sv[j].sc[s]); 85 else 86 printf(" -"); 87 } 88 printf("\n"); 89 } 90 return 0; 91 }
标签:
原文地址:http://www.cnblogs.com/fcp1024/p/4302025.html