标签:namespace rate cto 哈希 for mic span style ros
#include <bits/stdc++.h>
using namespace std;
int main(){
string t;
cin>>t;
int n=t.size();
string s1(n,‘a‘),s2(n,‘a‘),s3(n,‘a‘);
for(int i=0;i<n;i++){
s1[i]=char(‘a‘+(i%26));//从a到z循环
s2[i]=char(‘a‘+((i/26)%26));//第i位为(i/26)%26+‘a‘,保证了26*26内不会和s1相同
s3[i]=char(‘a‘+((i/26/26)%26));//保证了26^3内不会和s1相同,类似哈希编码
}
cout<<"? "<<s1<<endl;
string t1;
cin>>t1;
cout<<"? "<<s2<<endl;
string t2;
cin>>t2;
cout<<"? "<<s3<<endl;
string t3;
cin>>t3;
vector<int>p(n);
for(int i=0;i<n;i++)
p[i]=(t1[i]-‘a‘)+(t2[i]-‘a‘)*26+(t3[i]-‘a‘)*26*26;//将变化后的值根据编码还原
string s(n,‘a‘);
for(int i=0;i<n;i++)
s[p[i]]=t[i];//26^3>1000,所以可行
cout<<"! "<<s<<endl;
return 0;
}
Educational Codeforces Round 60 (Rated for Div. 2)E(思维,哈希,字符串,交互)
标签:namespace rate cto 哈希 for mic span style ros
原文地址:https://www.cnblogs.com/ldudxy/p/10486913.html