#include<iostream>
#include<vector>
using namespace std;
int main()
{
int a, b;
cin >> a >> b;
vector<string>V(a*(a-1)/2+1+a, "11");
while(b--)
{
string s;
int c = 0;
cin >> s;
for(int i=0;i<s.size();i++)
{
for(int j=i;j<s.size();j++)
{
if(s[j]<s[i])
{
c++;
}
}
}
while (V[c] != "11")
{
c++;
}
//cout << c << " ";
V[c] = s;
}
for (int i = 0; i < a*(a-1)/2+1+a; i++)
{
if (V[i] != "11")cout << V[i] << endl;
}
}
HNU软件实训-字符串排序(有缺陷)
于 2023-06-21 20:23:31 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)