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 |
ac#include<stdio.h> #include<string.h> #include<algorithm> using namespace std; struct node { int a; char s[1000]; }p[1000]; int cmp(node c,node b) { return c.a<b.a; } int main() { int m,n; while(~scanf("%d%d",&n,&m)) { for(int i=0;i<1000;i++) p[i].a=0; for(int i=0;i<m;i++) scanf("%s",p[i].s); for(int k=0;k<m;k++) for(int i=0;i<n;i++) for(int j=i+1;j<n;j++) if(p[k].s[i]>p[k].s[j]) p[k].a++; sort(p,p+m,cmp); for(int i=0;i<m;i++) printf("%s\n",p[i].s); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator