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"
#ifndef EVAL
#include "grader.cpp"
#endif
#include <string>
#include <vector>
using namespace std;
std::string guess_sequence(int N)
{
string known = "";
if (press("AB"))
known = (press("A") ? "A" : "B");
else
known = (press("X") ? "X" : "Y");
vector<char> letters;
if (known != "A")
letters.push_back('A');
if (known != "B")
letters.push_back('B');
if (known != "X")
letters.push_back('X');
if (known != "Y")
letters.push_back('Y');
if (N == 1)
return known;
for (int i = 1; i < N - 1; i++)
{
string str;
str = known;
str.push_back(letters[1]);
str.append(known);
str.push_back(letters[2]);
str.push_back(letters[0]);
str.append(known);
str.push_back(letters[2]);
str.push_back(letters[1]);
str.append(known);
str.push_back(letters[2]);
str.push_back(letters[2]);
known.push_back(letters[press(str) - known.size()]);
}
string str1, str2, str3;
str1.push_back(letters[0]);
str2.push_back(letters[1]);
str3.push_back(letters[2]);
if (press(known + str1) == N)
return known + str1;
if (press(known + str2) == N)
return known + str2;
return known + str3;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |