E - Decypher the String(交互题)

思路:利用分块的思想,逐步定位。

/*痛みを受け取れ,痛みを知れ*/
#include<bits/stdc++.h>
#define f(i,a,b) for(register int i=a;i<=b;++i)
#define ff(i,a,b) for(register int i=a;i>=b;--i)
#define debug(x) cerr << #x << " : " << x << " " << endl
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
const ll mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;
const double tiaohe = 0.57721566490153286060651209;
ll oula(ll x) { ll res = x;f(i, 2, x / i) { if (x % i == 0) { res = res / i * (i - 1);while (x % i == 0) x /= i; } }if (x > 1) res = res / x * (x - 1);return res; }
ll quickmod(ll a, ll n, ll m) { ll s = 1;while (n) { if (n & 1) { s = s * a % m; }a = (a*a) % m;n = n / 2; }return s; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
void ex_gcd(ll a, ll b, ll &x, ll &y, ll &d) { if (!b) { d = a, x = 1, y = 0; } else { ex_gcd(b, a % b, y, x, d);y -= x * (a / b); } }
ll inv(ll t, ll p) { ll d, x, y;ex_gcd(t, p, x, y, d);return d == 1 ? (x % p + p) % p : -1; }
bool isPrime(ll x) { if (x == 2)return true;if (x % 2 == 0)return false;for (ll i = 2;i*i <= x;i++) if (x % i == 0)return false; return true; }
//double a = log(n) +tiaohe + 1.0 / (2 * n);
double eqa = (1 + sqrt(5.0)) / 2.0;
const int N = 2e5 + 5;
int ans[3][N];
int ju[] = { 26 * 26,26,1 };
void ask(int k, int n)
{
	printf("? ");
	f(i, 1, n)
	{
		int pos = ceil(i*1.0 / ju[k]);//在哪个分块
		printf("%c", 'a' + ((pos - 1)%26));
	}
	cout << endl;
}
void solve(string s, int n)
{
	if (n != 0)
	{
		f(i, 0, N - 1)ans[n][i] = ans[n - 1][i];
	}
	f(i, 0, (int)s.size() - 1)ans[n][i] += ju[n] * (s[i] - 'a');
}
int main()
{
	string s, t;cin >> t;
	f(i, 0, 2)
	{
		ask(i, (int)t.size());
		cin >> s;
		solve(s, i);
	}
	printf("! ");
	string res = t;
	f(i, 0, (int)t.size() - 1)res[ans[2][i]] = t[i];
	cout << res << endl;
	return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值