怎么回事啊?

#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#include <cstring>
#include <vector>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iomanip>
using namespace std;

int main() {
//freopen("//xx.in","r",stdin);
//freopen("//xx.out","w",stdout);
string a;
cin>>a;
int n;
char p;
string word[1001];
cin>>n;
for (int i=1;i<=n;i++) cin>>word[i];
cin>>p;
if (p=='1')
{
int n1=0,n2=0;
for (int i=1;i<=n;i++)
{
for (int j=i+1;j<=n;j++)
{
int x=min(word[i].size(),word[j].size());
for (int k=0;k<=25;k++)
{
for (int l=0;l<=x-1;l++)
{
if (word[i][l]==a[k]) n1=k;
if (word[j][l]==a[k]) n2=k;
if (n1<n2) swap (word[i],word[j]);continue;
}

}
}
}

}
else
{
int n3=0,n4=0;
for (int i=1;i<=n;i++)
{
for (int j=i+1;j<=n;j++)
{
int y=min(word[i].size(),word[j].size());
for (int k=0;k<=25;k++)
{
for (int l=0;l<=y-1;l++)
{
if (word[i][l]==a[k]) n3=k;
if (word[j][l]==a[k]) n4=k;
if (n3<n4) swap (word[i],word[j]);continue;
}

}
}
}
}
for (int i=1;i<=n;i++) cout<<word[i]<<endl;
//fclose(stdin);
//fclose(stdout);
//while (1);
return 0;
}
TLE+WA

0 条评论

目前还没有评论...

信息

ID
1500
难度
6
分类
字符串 | 其他 | 排序 点击显示
标签
递交数
2884
已通过
721
通过率
25%
被复制
3
上传者