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 "combo.h"
#include <vector>
#include <algorithm>
std::string guess_sequence(int N)
{
using std::string;
using std::vector;
string res;
if(press("AB"))
if(press("A"))
res = "A";
else
res = "B";
else
if(press("X"))
res = "X";
else
res = "Y";
vector<char> avail{'A', 'B', 'X', 'Y'};
avail.erase(std::find(avail.begin(), avail.end(), res[0]));
for(int i = 1; i < N-1; ++i)
{
int type = press(res + avail[0] + res + avail[1] + avail[0] + res + avail[1] + avail[1] + res + avail[1] + avail[2]) - res.size();
if(type == 0)
res += avail[2];
else
if(type == 1)
res += avail[0];
else
res += avail[1];
}
if(N - 1)
{
int type = press(res + avail[0]) - res.size();
if(type == 0)
if(press(res + avail[1]) - res.size())
res += avail[1];
else
res += avail[2];
else
res += avail[0];
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |