# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
106347 | kig9981 | 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 <bits/stdc++.h>
using namespace std;
string guess_sequence(int N)
{
int i;
string ret;
string S="ABXY";
if(press("AB")) {
if(press("X")) ret="Y";
else ret="X";
}
else {
if(press("A")) ret="A";
else ret="B";
}
S.erase(ret[0]);
while(ret.size()<N) {
if(ret.size()+1==N) {
if(press(ret+S[0])==N) ret+=S[0];
else if(press(ret+S[1])==N) ret+=S[1];
else ret+=S[2];
}
else {
int temp=press(ret+S[0]+S[0]+ret+S[0]+S[1]+ret+S[1]+S[0]);
if(temp==ret.size()) ret.push_back(S[2]);
else if(temp==ret.size()+1) {
temp=press(ret+S[1]+S[1]);
if(temp==ret.size()) ret.push_back(S[0]), ret.push_back(S[2]);
else if(temp==ret.size()+1) ret.push_back(S[1]), ret.push_back(S[2]);
else ret.push_back(S[1]), ret.push_back(S[1]);
}
else {
temp=press(ret+S[0]+S[1]);
if(temp==ret.size()) ret.push_back(S[1]), ret.push_back(S[0]);
else if(temp==ret.size()+1) ret.push_back(S[0]), ret.push_back(S[0]);
else ret.push_back(S[0]), ret.push_back(S[1]);
}
}
}
return ret;
}