# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
224730 | ZwariowanyMarcin | 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 "combo.h"
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define ss(x) (int) x.size()
#define fi first
#define se second
#define cat(x) cerr << #x << " = " << x << endl
#define rep(i, j, n) for (int i = j; i <= n; ++i)
#define per(i, j, n) for (int i = n; j <= i; --i)
#define all(x) x.begin(), x.end()
using namespace std;
string S = "ABXY", q;
vector <int> res, qw;
int ask() {
q.clear();
for (auto it : qw)
q += S[it];
int x = press(q);
qw.clear();
return x;
}
void dod() {
for (auto it : res)
qw.pb(it);
}
string quess_sequence(int N) {
qw = {0, 1};
int a = ask();
if (a == 0) {
qw = {2};
int b = ask();
if (b > 0) res.pb(2);
if (b == 0) res.pb(3);
}
if (a > 0) {
qw = {0};
int b = ask();
if (b > 0) res.pb(0);
if (b == 0) res.pb(1);
}
vector <int> re;
for (int i = 0; i < 4; ++i)
if (i != res[0])
re.pb(i);
for (int i = 2; i < N; ++i) {
dod();
qw.pb(re[0]);
dod();
qw.pb(re[1]);
qw.pb(re[0]);
dod();
qw.pb(re[1]);
qw.pb(re[1]);
dod();
qw.pb(re[1]);
qw.pb(re[2]);
int b = ask();
if (b == i) {
res.pb(re[0]);
}
if (b == i + 1) {
res.pb(re[1]);
}
if (b == i - 1) {
res.pb(re[2]);
}
}
if (N > 1) {
rep(i, 0, 2) {
if (i == 2) {
res.pb(re[2]);
break;
}
dod();
qw.pb(re[i]);
int b = ask();
if (b == N) {
res.pb(re[i]);
break;
}
}
}
string ans = "";
for (auto it : res)
ans += S[it];
return ans;
}