# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
796997 | polya | 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;
char d[4] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int N) {
string seq;
int ans = 0, data;
for (int i=0; i<3; i++) {
string a; a.push_back(d[i]);
ans = press(a);
if (ans == 1) {
data = i;
seq.push_back(d[i]);
break;
}
}
if (ans == 0) {
seq.push_back(d[3]);
for (int i=1; i<N; i++) {
string a = seq; a.push_back('A');
ans = press(a);
if (ans == a.size()) seq.push_back('A');
else {
string b = seq; b.push_back('B');
ans = press(b);
if (ans == b.size()) seq.push_back('B');
else seq.push_back('X');
}
}
}
else {
for (int i=1; i<N; i++) {
for (int j=0; j<2; j++) {
if (j != data) {
string a = seq;
a.push_back(d[j]);
ans = press(a);
if (ans == a.size()) {
seq.push_back(d[j]);
break;
}
}
}
if (seq.size() != i+1) seq.push_back('Y');
}
}
return seq;
}