本来考虑生成abcd...xyz的全排列打一个长10000的表,用的这段代码:
#include<bits/stdc++.h>
using namespace std;
char ans[27];
const int n=26;
int cnt;
int main()
{
freopen("1.txt","w",stdout);
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
for(int i=1;i<=n;i++)ans[i]='a'+i-1;
do
{
for(int i=1;i<=n;i++)cout<<ans[i];
cnt+=26;
if(cnt>10000)
{
return 0;
}
}while(next_permutation(ans+1,ans+n+1));
return 0;
}
然后把表复制到这个程序里:
#include<bits/stdc++.h>
using namespace std;
int n;
string ans="abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxzyabcdefghijklmnopqrstuvwyxzabcdefghijklmnopqrstuvwyzxabcdefghijklmnopqrstuvwzxyabcdefghijklmnopqrstuvwzyxabcdefghijklmnopqrstuvxwyzabcdefghijklmnopqrstuvxwzyabcdefghijklmnopqrstuvxywzabcdefghijklmnopqrstuvxyzwabcdefghij";//以下省略
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin>>n;
for(int i=0;i<n;i++)cout<<ans[i];
return 0;
}
然后Subtask2全错。
后来发现表打小了,但如果方法是对的不至于整个Subtask一个点过不去吧。