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 |
wrong answer#include<iostream> #include<stdio.h> #include<set> using namespace std; int count(string str); struct cmp { bool operator() (string str1,string str2) { int count1=count(str1); int count2=count(str2); return count1<count2; } }; int main(void) { int n,m; scanf("%d %d",&n,&m); string str; set<string,cmp> s; for(int i=0;i<m;i++) { cin>>str; s.insert(str); } for(set<string>::iterator it=s.begin();it!=s.end();it++) { cout<<*it<<endl; } return 0; } int count(string str) { int length=str.length(); int count=0; for(int i=0;i<length;i++) { for(int j=i+1;j<length;j++) { if(str[i]>str[j]) { count++; } } } return count; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator