最近写水题各种错,本来写的时候就没什么信心,结果此题WA2次,给我们队造成了巨大的损失,最后还一个队友过来帮我检查。赛后再写还WA一次。难道是太久没写水题了~~? #include<cstdio> #include<cstring> #include<algorithm> #define N 1005 using namespace std; struct P{ int sc,num,id; }; P per[N]; int sta[N]; bool cmp(P a,P b) { if (a.sc!=b.sc) return a.sc>b.sc; if (a.num!=b.num) return a.num>b.num; return a.id<b.id; } int main() { int n,s,p,i,j,a,score,top; while (scanf("%d%d%d",&n,&s,&p)!=EOF){ memset(per,0,sizeof(per)); for (j=1;j<=s;j++) per[j].id=j; for (i=1;i<=n;i++){ score=top=0; for (j=1;j<=s;j++){ scanf("%d",&a); if (a==0) score++; else sta[top++]=j; } while (top){ per[sta[--top]].num++; per[sta[top]].sc+=score; } } sort(per+1,per+s+1,cmp); for (i=1;i<=s;i++) if (per[i].id==p) break; printf("%d %d/n",per[i].sc,i); } return 0; }