| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1339413 | vjudge1 | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
#define ll long long
const ll MOD = 1e9 + 7;
ll ask(ll r, ll c) {
cout << "? " << r << " " << c << endl;
ll d; cin >> d;
return d;
}
string guess_sequence(int N) {
string bs = "ABXY";
string s = "";
if (press("AB")) {
if (press("A")) s = "A";
else s = "B";
} else {
if (press("X")) s = "X";
else s = "Y";
}
if (N == 1) return s;
string p = "";
for (char c : bs) {
if (c != s[0]) p += c;
}
for (int i = 1; i < N - 1; ++i) {
string q = s + p[0] + p[0] + s + p[0] + p[1] + s + p[0] + p[2] + s + p[1];
int res = press(q);
if (res == s.size() + 2) {
s += p[0];
} else if (res == s.size() + 1) {
s += p[1];
} else {
s += p[2];
}
}
if (press(s + p[0]) == N) {
s += p[0];
} else if (press(s + p[1]) == N) {
s += p[1];
} else {
s += p[2];
}
return s;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
int t = 1; // cin >> t;
while (t--) guess_sequence();
return 0;
}