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 |
暴力16ms#include<stdio.h> #include<string> #include<string.h> #include<algorithm> #include<map> #include<set> #include<queue> #include<vector> #include<iostream> #include<stack> #include<cmath> using namespace std; typedef struct st { char s[110]; int m; }st; int cmp(st a, st b) { return a.m<b.m; } st a[60]; int main(void) { int n,m; while(scanf("%d %d",&n,&m)!=EOF) { for(int i=0;i<m;i++) { getchar(); scanf("%s",a[i].s); } for(int i=0;i<m;i++) { a[i].m=0; for(int j=0;j<n;j++) { for(int k=j+1;k<n;k++) { if(a[i].s[j]>a[i].s[k]) a[i].m++; } } } sort(a,a+m,cmp); for(int i=0;i<m;i++) { printf("%s\n",a[i].s); } } //int c; //cin>>c; return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator