# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
321036 | gustason | 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>
//#include "combo.h"
using namespace std;
int press(string s) {
int a;
cout << s << "\n";
cin >> a;
return a;
}
string guess_sequence(int N) {
string keys[] = {"A", "B", "X", "Y"};
string S = "";
if (press("AB") >= 1) {
if (press("A") == 1) {
S += 'A';
} else {
S += 'B';
}
} else {
if (press("X") >= 1) {
S += 'X';
} else {
S += 'Y';
}
}
vector<string> add;
if (S == "B") {
add.push_back("X");
} else {
add.push_back("B");
}
string fr;
if (S == "X") {
fr += "B";
} else {
fr += "X";
}
vector<string> keys2;
for(int i = 0; i < 4; i++) {
if (keys[i] == S) continue;
keys2.push_back(keys[i]);
add.push_back(fr + keys[i]);
}
int sz = 1;
for(int i = 1; i < N-1; i++, sz++) {
int p = press(S + add[0] + S + add[1] + S + add[2] + S + add[3]);
if (p == sz) {
S += add[3][1];
} else if (p == sz + 1) {
S += add[0][0];
} else {
S += add[1][0];
}
}
if (press(S + keys[0] + S + keys[1]) == sz) {
S += keys[2];
} else {
if (press(S + keys[0]) == sz + 1) {
S += keys[0];
} else {
S += keys[1];
}
}
return S;
}
int main() {
cout << guess_sequence(3);
}