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.bp 添加宏开关【转】
本文转载自:https://github.com/zzb2760715357/document/blob/master/android_doc/Android.bp%E6%B7%BB%E5%8A%A0 ...
- 浅尝flutter中的http请求
import 'package:flutter/material.dart'; class News extends StatefulWidget { final String title,imgli ...
- 分布式事务框架&解决方案参考
两种开源解决方案框架介绍: https://blog.csdn.net/zyndev/article/details/79604395#_97 LCN: https://www.jianshu.com ...
- 关于C#引用ExceptionPolicy.HandleException(ex, "LogAndReplace", out exceptionToReplace);
http://www.cnblogs.com/Terrylee/archive/2006/07/03/enterprise_library2_1.html 要使用ExceptionPolicy.Han ...
- Hadoop之mapreduce
doc Hadoop初探之Stream Hadoop Stream 用python + hadoop streaming 编写分布式程序(一) -- 原理介绍,样例程序与本地调试 用python + ...
- python学习 day07打卡 文件操作
本节主要内容: 初识文件操作 只读(r,rb) 只读(w,wb) 追加(a,ab) r+读写 w+写读 a+追加写读 其他操作方法 文件的修改以及另一种打开文件句柄的方法 一. 初识文件操作 使用py ...
- openlayers空间点查询之GetFeatureInfo
在map对象上注册点击方法监听, 这里我用的是wms,当然你也可以查询wfs map.events.register('click', map, function (e) { ...
- Spring-test单元测试
<dependency> <groupId>org.springframework</groupId> <artifactId>spring-test& ...
- ImgQuoteUIWindow
using System;using UnityEngine;using UnityEngine.UI;using UnityEditor;using System.Collections;using ...
- PL/SQL Developer安装配置
选择tool下的perferences 修改下面标记的内容即可