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 <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N)
{
string s, p;
char option[4] = {'A', 'B', 'X', 'Y'};
int x;
p = "AB";
x = press(p);
if (x != 0)
{
p = "A";
x = press(p);
if (x != 0)
{
s = "A";
}
else
{
s = "B";
swap (option[0], option[1]);
}
}
else
{
p = "X";
x = press(p);
if (x != 0)
{
s = "X";
swap (option[0], option[2]);
}
else
{
s = "Y";
swap (option[0], option[3]);
}
}
while ((int)s.size() < N - 1)
{
p.clear();
p += s;
p += option[1];
p += option[1];
p += s;
p += option[1];
p += option[2];
p += s;
p += option[1];
p += option[3];
p += s;
p += option[2];
p += option[0];
x = press (p);
if (x == (int)s.size())
s += option[3];
if (x == (int)s.size() + 1)
s += option[2];
if (x == (int)s.size() + 2)
s += option[1];
}
s += option[1];
if (press (s) == N)
return s;
s.pop_back();
s += option[2];
if (press(s) == N)
return s;
s.pop_back();
s += option[3];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |