# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
832700 | kamelfanger83 | 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 <iostream>
#include <vector>
#include <string>
using namespace std;
string guess_sequence(int N){
bool f = press(string("ab")), s = press(string("ax"));
string res;
if (f && s) res = "a";
else if (f) res = "b";
else if (s) res = "x";
else res = "y";
vector<string> lchars;
for (auto c : {'a', 'b', 'x', 'y'}) if (c != res[0]) lchars.push_back("" + c);
while (res.size() < N){
int ans = press(res + lchars[0] + lchars[0] + res + lchars[0] + lchars[1] + res + lchars[1] + lchars[0]);
if (ans == res.size()) res += lchars[2];
if (ans == res.size() + 1) {
int sans = press(res + lchars[1] + lchars[1]);
if (sans == res.size()) res += lchars[0] + lchars[2];
if (sans == res.size() + 1) res += lchars[1] + lchars[2];
else res += lchars[1] + lchars[1];
}
else {
int sans = press(res + lchars[0] + lchars[0]);
if (sans == res.size()) res += lchars[1] + lchars[0];
if (sans == res.size() + 1) res += lchars[0] + lchars[1];
else res += lchars[0] + lchars[0];
}
}
return res;
}