You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
713 B
32 lines
713 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
const int N = 110;
|
|
int getWuXu(string x){
|
|
int sum = 0;
|
|
for (int i = 0; i < x.size(); i++)
|
|
for (int j = i + 1; j < x.size();j++)
|
|
if (x[i] > x[j]) sum++;
|
|
return sum;
|
|
}
|
|
|
|
struct Node{
|
|
int id;
|
|
string s;
|
|
int wxd;
|
|
const bool operator<(const Node &t){
|
|
if (wxd == t.wxd) return id < t.id;
|
|
return wxd < t.wxd;
|
|
}
|
|
} a[N];
|
|
int main() {
|
|
int n, m;
|
|
cin >> n >> m;
|
|
for (int i = 0; i < m;i++){
|
|
cin >> a[i].s;
|
|
a[i].id = i, a[i].wxd = getWuXu(a[i].s);
|
|
}
|
|
sort(a, a + m);
|
|
for (int i = 0; i < m;i++)
|
|
cout << a[i].s << endl;
|
|
return 0;
|
|
} |