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;
char characters[4] = {'A', 'B', 'X', 'Y'};
void find_and_replace_first_character()
{
string S(characters, 2);
if (press(S) > 0)
{
S = string(characters, 1);
if (press(S) == 0)
swap(characters[0], characters[1]);
}
else
{
S = string(characters + 2, 1);
if (press(S) > 0)
swap(characters[0], characters[2]);
else
swap(characters[0], characters[3]);
}
}
string guess_sequence(int n) {
find_and_replace_first_character();
string S(characters, 1);
if (n == 1)
return S;
for (int i = 1; i < n - 1; i++)
{
string query = S;
query += characters[1];
for (int j = 1; j <= 3; j++)
{
query += S;
query += characters[2];
query += characters[j];
}
int res = press(query);
if (res == i)
S += characters[3];
else if (res == i+1)
S += characters[1];
else if (res == i+2)
S += characters[2];
else
assert(false);
}
if (press(S + characters[1]) == n)
return S + characters[1];
else if (press(S + characters[2]) == n)
return S + characters[2];
else
return S + characters[3];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |