# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
526739 | lcs147 | 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.
string guess_sequence(int n) {
vector<char> possible = {'A','B','X','Y'};
char first = possible.back();
int cnt = 1;
for(int i=0; i<3; i++) {
char c = possible[i];
int sz = press(string(n, c));
if(sz > 0) {
cnt = sz;
first = c;
break;
}
}
string res = string(cnt, first);
possible.erase(find(possible.begin(), possible.end(), first));
auto allpossible = possible;
while(res.size() < n) {
if(possible.size() == 2) {
int cur = possible[1];
int cnt = 1;
int sz = press(res + string(n, possible[0]));
bool is0 = false;
if(sz > res.size()) {
cur = possible[0];
cnt = sz-res.size();
is0 = true;
}
res += string(cnt, cur);
possible = allpossible;
if(is0) {
possible.erase(find(possible.begin(), possible.end(), cur));
}
} else {
int sz = press(res + string(n, possible[0]) + res + string(n, possible[1]));
if(sz == res.size()) {
res += possible[2];
possible = allpossible;
} else {
int id = 1;
if(press(res + string(n, possible[0])) > res.size()) {
id = 0;
}
res += string(sz-res.size(), possible[id]);
possible = allpossible;
possible.erase(find(possible.begin(), possible.end(), possible[id]));
}
}
}
return res;
}