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>
using namespace std;
string guess_sequence(int n)
{
string s = "";
if (press("AB") >= 1)
{
if (press("A") >= 1) s += 'A';
else s += 'B';
}
else
{
if (press("X") >= 1) s += 'X';
else s += 'Y';
}
if (n == 1) return s;
vector<char> chars{'A', 'B', 'X', 'Y'};
chars.erase(find(chars.begin(), chars.end(), s.front()));
for (int i = 1; i + 1 < n; ++i)
{
int c = press(s + chars[0] + s + chars[1] + chars[0] + s + chars[1] + chars[1] + s + chars[1] + chars[2]);
if (c == i) s += chars[2];
else if (c == i + 1) s += chars[0];
else s += chars[1];
}
if (press(s + 'A' + s + 'B') == n)
{
if (press(s + 'A') == n) s += 'A';
else s += 'B';
}
else
{
if (press(s + 'X') == n) s += 'X';
else s += 'Y';
}
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |