标签:
排序。。就是数据有点坑爹。。
#include<cstdio> #include<cstring> #include<iostream> #include<algorithm> using namespace std; struct sbjjq{ int z,x,c,v,b,q; }a[100005],r; int n,t,i,m; bool pd(sbjjq x,sbjjq y){return x.z!=y.z||x.x!=y.x||x.c!=y.c||x.v!=y.v||x.b!=y.b||x.q!=y.q;} bool compare(sbjjq x,sbjjq y){ return(x.z<y.z||x.z==y.z&&(x.x<y.x||x.x==y.x&&(x.c<y.c||x.c==y.c&&(x.v<y.v||x.v==y.v&&(x.b<y.b||x.b==y.b&&x.q<y.q))))); } int main(){ scanf("%d",&t); while(t--){ scanf("%d",&n); for (i=1;i<=n;i++) scanf("%d%d%d%d%d%d",&a[i].z,&a[i].x,&a[i].c,&a[i].v,&a[i].b,&a[i].q); sort(a+1,a+n+1,compare); r=a[1];m=1; for (i=2;i<=n;i++){ if(pd(a[i],r)){ printf("%02d %08d %04d %04d %04d %04d %d\n",r.z,r.x,r.c,r.v,r.b,r.q,m); r=a[i];m=1; }else m++; } printf("%02d %08d %04d %04d %04d %04d %d\n",r.z,r.x,r.c,r.v,r.b,r.q,m); } }
SPOJ Problem 27:Sorting Bank Accounts
标签:
原文地址:http://www.cnblogs.com/moris/p/4342709.html