#include<iostream>
#include<string>
#include<map>
using namespace std;
int inversionCompute(string str){
int inversionSum=0;
char *cp=(char*)str.data();
for(int i=0;i<str.length()-1;i++){
for(int j=i;j<str.length()-1;j++){
if(cp[i]>cp[j+1]){
inversionSum++;
}
}
}
return inversionSum;
}
int main(int argc, char *argv[]){
int rowSize, lineNum;
cin>>rowSize>>lineNum;
string dnaSequence;
multimap<int,string> intMap;
for(int i=0;i<lineNum;i++){
cin>>dnaSequence;
intMap.insert(make_pair(inversionCompute(dnaSequence),dnaSequence));
}
for(multimap<int, string>::iterator iter=intMap.begin();iter!=intMap.end();++iter){
cout<<iter->second<<endl;
}
return 0;
}
POJ-1007
最新推荐文章于 2019-01-15 11:35:44 发布