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 First;
string letters;
char FindFirst () {
if (press("A")) return 'A';
if (press("B")) return 'B';
if (press("X")) return 'X';
return 'Y';
}
string ans;
char FindCaracter (int sz) {
string query = ans + letters[0] + ans + letters[1] + letters[0] + ans + letters[1] + letters[1] + ans + letters[1] + letters[2];
int lg = press(query);
if (lg == sz + 1) return letters[1];
if (lg == sz) return letters[0];
return letters[2];
}
char FindLast (int N) {
string query = ans + letters[0];
int lg = press(query);
if (lg == N) return letters[0];
query = ans + letters[1];
lg = press(query);
if (lg == N) return letters[1];
return letters[2];
}
std::string guess_sequence(int N) {
First = FindFirst();
if (First == 'A') letters = "BXY";
if (First == 'B') letters = "AXY";
if (First == 'X') letters = "ABY";
if (First == 'Y') letters = "ABX";
ans = First;
for (int i = 2; i < N; ++ i )
ans += FindCaracter(i);
ans += FindLast(N);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |