# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
78708 | wleung_bvg | Combo (IOI18_combo) | C++14 | 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>
using namespace std;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define f first
#define s second
#define all(a) (a).begin(),(a).end()
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define FOR(i,b) For(i,0,b)
#define Rev(i,a,b) for(auto i=(a);i>(b);i--)
#define REV(i,a) Rev(i,a,-1)
#define FORE(i,a) for(auto&&i:a)
#define sz(a) (int((a).size()))
using ll=long long;using ld=long double;using uint=unsigned int;using ull=unsigned long long;
using pii=pair<int,int>;using pll=pair<ll,ll>;using pill=pair<int,ll>;using plli=pair<ll,int>;using pdd=pair<double,double>;using pld=pair<ld,ld>;
constexpr const char nl='\n',sp=' ';constexpr const int INT_INF=0x3f3f3f3f;constexpr const ll LL_INF=0x3f3f3f3f3f3f3f3f;
constexpr const double D_INF=numeric_limits<double>::infinity();constexpr const ld LD_INF=numeric_limits<ld>::infinity();constexpr const double EPS=1e-9;
// int press(string p) {
// cout << "?" << sp << p << nl;
// cout.flush();
// int x;
// cin >> x;
// return x;
// }
string guess_sequence(int N) {
string S = press("AB") ? (press("A") ? "A" : "B") : (press("X") ? "X" : "Y");
if (N == 1) return S;
string ch = "";
FORE(c, "ABXY") if (S[0] != c) ch.pb(c);
For(i, 1, N - 1) S.pb(ch[press(S + ch[1] + S + ch[2] + ch[0] + S + ch[2] + ch[1] + S + ch[2] + ch[2]) - i]);
return press(S + ch[0] + S + ch[1]) == N ? (press(S + ch[0]) == N ? S + ch[0] : S + ch[1]) : (S + ch[2]);
}
int main() {
// freopen("in.txt", "r", stdin);
// freopen("out.txt", "w", stdout);
ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int N;
cin >> N;
cout << guess_sequence(N) << nl;
return 0;
}