Educational Codeforces Round 60 (Rated for Div. 2)E(思维,哈希,字符串,交互)

#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;
}

原文地址:https://www.cnblogs.com/ldudxy/p/10486913.html

时间: 2024-11-01 10:49:51

Educational Codeforces Round 60 (Rated for Div. 2)E(思维,哈希,字符串,交互)的相关文章

Educational Codeforces Round 60 (Rated for Div. 2)

A. Best Subsegment 题意 找 连续区间的平均值  满足最大情况下的最长长度 思路:就是看有几个连续的最大值 1 #include<bits/stdc++.h> 2 using namespace std; 3 const int maxn= 1e5+4; 4 int a[maxn]; 5 int main(){ 6 int n; 7 scanf("%d",&n); 8 int maxnum=0; 9 for(int i=0;i<n;i++)s

Educational Codeforces Round 60 (Rated for Div. 2) E. Decypher the String

题目大意:这是一道交互题.给你一个长度为n的字符串,这个字符串是经过规则变换的,题目不告诉你变换规则,但是允许你提问3次:每次提问你给出一个长度为n的字符串,程序会返回按变换规则变换后的字符串,提问3次后你需要猜出这个字符串.解法是学习https://blog.csdn.net/baiyifeifei/article/details/87807822 这个博主的,借用了进制的思想非常巧妙. 解法:对于某个位置的来源位置我们设为x,因为26*26*26>10000,那么x可以唯一表示为x=a*26

Educational Codeforces Round 60 (Rated for Div. 2) A. Best Subsegment

time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output You are given array a 1 , a 2 ,-, a n a1,a2,-,an . Find the subsegment a l , a l+1 ,-, a r al,al+1,-,ar ( 1≤l≤r≤n 1≤l≤r≤n ) with maximum arithmet

Educational Codeforces Round 60 (Rated for Div. 2) D. Magic Gems(矩阵快速幂)

题目传送门 题意: 一个魔法水晶可以分裂成m个水晶,求放满n个水晶的方案数(mol1e9+7) 思路: 线性dp,dp[i]=dp[i]+dp[i-m]; 由于n到1e18,所以要用到矩阵快速幂优化 注意初始化 代码: #include<bits/stdc++.h> using namespace std; #define mod 1000000007 typedef long long ll; #define MAX 105 const int N=105;//矩阵的大小 int T; ll

Educational Codeforces Round 60 (Rated for Div. 2)D(思维,DP,快速幂)

#include <bits/stdc++.h>using namespace std;const long long mod = 1e9+7;unordered_map<long long,long long>mp;long long n,m;long long dp(long long n){    if(n<0)        return 0;    if(n<m)        return 1;    if(mp.find(n)!=mp.end())//已经

Educational Codeforces Round 36 (Rated for Div. 2)

Educational Codeforces Round 36 (Rated for Div. 2) F. Imbalance Value of a Tree You are given a tree T consisting of n vertices. A number is written on each vertex; the number written on vertex i is ai. Let's denote the function I(x,?y) as the differ

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars

Educational Codeforces Round 69 (Rated for Div. 2) B - Pillars There are n pillars aligned in a row and numbered from 1 to n. Initially each pillar contains exactly one disk. The i-th pillar contains a disk having radius ai. You can move these disks

Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations

原文链接:https://www.cnblogs.com/xwl3109377858/p/11405773.html Educational Codeforces Round 71 (Rated for Div. 2) D - Number Of Permutations You are given a sequence of n pairs of integers: (a1,b1),(a2,b2),…,(an,bn). This sequence is called bad if it is

Educational Codeforces Round 36 (Rated for Div. 2) 题解

Educational Codeforces Round 36 (Rated for Div. 2) 题目的质量很不错(不看题解做不出来,笑 Codeforces 920C 题意 给定一个\(1\)到\(n\)组成的数组,只可以交换某些相邻的位置,问是否可以将数组调整为升序的 解题思路 首先如果每个数都能通过交换到它应该到的位置,那么就可以调整为升序的. 但实际上交换是对称的,如果应该在的位置在当前位置前方的数都交换完成,那么整体就是排好序的,因为不可能所有不在相应位置的数都在相应位置的后方.