Memory Exceeded
代码
#include<bits/stdc++.h>
using namespace std;
string sss,s[100000];
int main()
{
// freopen("sort.in","r",stdin);
// freopen("sort.out","w",stdout);
int n,m;
cin>>n>>m;
cin>>sss;
int k=0;
for (int i=0;i<=n-1;i++)
{
k++;
for (int j=i;j<=i+m-1;j++)
{
s[k]+=sss[j];
}
}
int ans=0;
for (int i=1;i<=k;i++)
for (int j=1;j<=k-1;j++)
{
if (s[j]>s[j+1]) swap(s[j],s[j+1]),ans++;
}
cout<<ans;
}