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 "combo.h"
char let[4] = {'A', 'B', 'X', 'Y'};
std::string ans, guess;
std::string guess_sequence(int n)
{
int res = press("AB"), letIdx;
if (res)
{
if (press("A")) ans = "A", letIdx = 0;
else ans = "B", letIdx = 1;
} else
{
if (press("X")) ans = "X", letIdx = 2;
else ans = "Y", letIdx = 3;
}
if (n == 1) return ans;
std::swap(let[letIdx], let[3]);
for (int i = 2 ; i <= n-1 ; ++i)
{
guess = ans; guess += let[0];
guess += ans + let[1] + let[0];
guess += ans + let[1] + let[1];
guess += ans + let[1] + let[2];
int res = press(guess);
if (res == i) ans += let[0];
if (res == i+1) ans += let[1];
if (res == i-1) ans += let[2];
}
guess = ans + let[0];
if (press(guess) == n) return ans += let[0];
guess = ans + let[1];
if (press(guess) == n) return ans += let[1];
return ans += let[2];
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |