# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1010216 | baotoan655 | Combo (IOI18_combo) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#ifdef ONLINE_JUDGE
#include "combo.h"
#endif
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
#define FOR(i, a, b) for(int i = (a); i <= (b); ++i)
#define FOD(i, b, a) for(int i = (b); i >= (a); --i)
#define ll long long
#define fi first
#define se second
using namespace std;
#ifndef ONLINE_JUDGE
int press(string p) {
// cout << p << '\n';
int x;
cin >> x;
return x;
}
#endif
string guess_sequence(int N) {
string s;
if(press("AB")) {
if(press("A")) s = "A";
else s = "B";
} else {
if(press("X")) s = "X";
else s = "Y";
}
vector<string> ve;
for(string str : {"A", "B", "X", "Y"}) if(str != s) ve.emplace_back(str);
while(s.size() < N) {
// cout << s << ' ';
string p;
p = s;
p += ve[0];
p += s;
p += ve[1]; p += ve[0];
p += s;
p += ve[1]; p += ve[1];
p += s;
p += ve[1]; p += ve[2];
int res = press(p);
int sz = s.size();
if(res == sz + 1) s += ve[0];
else if(res == sz + 2) s += ve[1];
else s += ve[2];
}
return s;
}
#ifndef ONLINE_JUDGE
int32_t main() {
string s;
cin >> s;
string tmp = guess_sequence((int)s.size());
cout << tmp;
}
#endif