您的答案為: OOZGHJPDXFIQVDWRFMBGXUCSSUFZCZZQNYYWIPZHWJZRMXLRJM
正確答案為: SDFFHIAHMQINBGGGNQQSGPZKWEGBCFZULFBUPDBBTKPXQVDGNV
#include<bits/stdc++.h>
using namespace std;
bool cmp(pair<int,string> a,pair<int,string> b)
{
if(a.first!=b.first) return a.first<b.first;
return 0;
}
int count(string);
int main()
{
int t;
cin>>t;
//getchar();
while(t--)
{
int t2;
cin.ignore(10,' ');
cin>>t2;
// cout<<t2<<" ";
pair<int,string> m[t2];
for(int i=0;i<t2;i++)
{
string s;
cin>>s;
m[i]=make_pair(count(s),s);
}
sort(m,m+t2,cmp);
for(int i=0;i<t2;i++) cout<<m[i].second<<"\n";
//cout<<"\n";
}
}
inline int count(string s)
{
char c[s.length()];
//int n[s.length()];
int sum=0,length=s.length();
for(int i=0;i<length;i++) c[i]=s[i];
sort(c,c+length);
for(int i=0;i<length;i++)
{
for(int j=i;j<length;j++) if(s[j]<s[i]) sum++;
}
//cout<<sum<<" ";
return sum;
}
請問為何我把sort改成stable_sort就會AC?