CF1117E Decypher the String
如果我们能询问一个排列的话,我们就可以得到这个置换,然后反向求解。
但现在字符集只有26。
考虑26^3>1e5。
用一个三维坐标去映射到一个一维整数,然后就可以构造排列了。
#include<bits/stdc++.h>
#define N 1100000
#define eps 1e-7
#define inf 1e9+7
#define db double
#define ll long long
#define ldb long double
using namespace std;
inline int read()
{
char ch=0;
int x=0,flag=1;
while(!isdigit(ch)){ch=getchar();if(ch=='-')flag=-1;}
while(isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=getchar();}
return x*flag;
}
char s[N],s1[N],s2[N],s3[N],t1[N],t2[N],t3[N],ans[N];
int main()
{
scanf("%s",s+1);int n=strlen(s+1),cnt=0;
for(int i=0;i<26;i++)for(int j=0;j<26;j++)for(int k=0;k<26;k++)
if(cnt!=n)s1[++cnt]=i+'a',s2[cnt]=j+'a',s3[cnt]=k+'a';
printf("? ");for(int i=1;i<=n;i++)printf("%c",s1[i]);printf("\n");fflush(stdout);
fflush(stdin);scanf("%s",t1+1);
printf("? ");for(int i=1;i<=n;i++)printf("%c",s2[i]);printf("\n");fflush(stdout);
fflush(stdin);scanf("%s",t2+1);
printf("? ");for(int i=1;i<=n;i++)printf("%c",s3[i]);printf("\n");fflush(stdout);
fflush(stdin);scanf("%s",t3+1);
for(int i=1;i<=n;i++)ans[(t1[i]-'a')*26*26+(t2[i]-'a')*26+(t3[i]-'a')+1 ]=s[i];
printf("! ");for(int i=1;i<=n;i++)printf("%c",ans[i]);printf("\n");fflush(stdout);
return 0;
}
CF1117E Decypher the String的更多相关文章
- CF 1117 E. Decypher the String
E. Decypher the String 链接 题意: 有一个字符串,一些操作,每次操作交换两个位置的字符,经过这些操作后,会得到新的字符串.给你新的字符串,求原来的串.可以有3次询问,每次询问给 ...
- Educational Codeforces Round 60 (Rated for Div. 2) E. Decypher the String
题目大意:这是一道交互题.给你一个长度为n的字符串,这个字符串是经过规则变换的,题目不告诉你变换规则,但是允许你提问3次:每次提问你给出一个长度为n的字符串,程序会返回按变换规则变换后的字符串,提问3 ...
- CF集萃2
CF1155D - Beautiful Array 题意:给你一个序列和x,你可以选择任意一个子串(可以为空)乘上x,使得得到的序列最大子串和最大.求这个最大值.30w,2s. 解:设fi,0/1/2 ...
- Educational Codeforces Round 60 (Rated for Div. 2) 题解
Educational Codeforces Round 60 (Rated for Div. 2) 题目链接:https://codeforces.com/contest/1117 A. Best ...
- Codeforces Edu Round 60 A-E
A. Best Subsegment 显然,选择数列中的最大值当做区间(长度为\(1\)).只要尝试最大值这个区间是否能扩展(左右两边值是否跟它一样就行了) #include <cstdio&g ...
- 透过WinDBG的视角看String
摘要 : 最近在博客园里面看到有人在讨论 C# String的一些特性. 大部分情况下是从CODING的角度来讨论String. 本人觉得非常好奇, 在运行时态, String是如何与这些特性联系上的 ...
- JavaScript String对象
本编主要介绍String 字符串对象. 目录 1. 介绍:阐述 String 对象的说明以及定义方式. 2. 实例属性:介绍 String 对象的实例属性: length. 3. 实例方法:介绍 St ...
- ElasticSearch 5学习(9)——映射和分析(string类型废弃)
在ElasticSearch中,存入文档的内容类似于传统数据每个字段一样,都会有一个指定的属性,为了能够把日期字段处理成日期,把数字字段处理成数字,把字符串字段处理成字符串值,Elasticsearc ...
- [C#] string 与 String,大 S 与小 S 之间没有什么不可言说的秘密
string 与 String,大 S 与小 S 之间没有什么不可言说的秘密 目录 小写 string 与大写 String 声明与初始化 string string 的不可变性 正则 string ...
随机推荐
- Android O HIDL的实现对接【转】
本文转载自:https://blog.csdn.net/gh201030460222/article/details/80551897 Android O HIDL的实现对接1. HIDL的定义1.1 ...
- [转]抓取当前登录用户登录密码的工具:mimipenguin
Github项目地址 前有Mimikatz,今有mimipenguin,近日国外安全研究员huntergregal发布了工具mimipenguin,一款Linux下的密码抓取神器,可以说弥补了Linu ...
- 题解——CF Manthan, Codefest 18 (rated, Div. 1 + Div. 2) T5(思维)
还是dfs? 好像自己写的有锅 过不去 看了题解修改了才过qwq #include <cstdio> #include <algorithm> #include <cst ...
- 题解——loj6278 数列分块入门2 (分块)
查询小于k的值 注意lower_bound一定要减去查找的起始位置得到正确的位置 调了快两天 淦 #include <cstdio> #include <algorithm> ...
- elastic-job的原理简介和使用
转载:http://blog.csdn.net/fanfan_v5/article/details/61310045 elastic-job是当当开源的一款非常好用的作业框架,在这之前,我们开发定时任 ...
- 【NOI 2016】优秀的拆分
Problem Description 如果一个字符串可以被拆分为 \(AABB\) 的形式,其中 \(A\) 和 \(B\) 是任意非空字符串,则我们称该字符串的这种拆分是优秀的. 例如,对于字符串 ...
- Lintcode449-Char to Integer-Naive
Description Convert a char to an integer. You can assume the char is in ASCII code (See Definition, ...
- Chrome,你这坑人的默认非安全端口
今天用chrome打开页面的发现一个错误: ERR_UNSAFE_PORT 字面意思是error:不安全端口. 一.什么是默认非安全端口? 每个浏览器出于安全问题,都会禁止一些网络浏览以外的端口 ...
- ERR! registry error parsing json
报错日志: ERR! registry error parsing json ERR! registry error parsing json 解决过程: 从github上克隆一个项目,在npm i的 ...
- go helloworld
// Sample program to show how a bytes.Buffer can also be used // with the io.Copy function. package ...