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;
int n;
string solve(string s, string t, string u, string v) {
string ans, query;
ans = s;
for (int i = 2; i < n; i++) {
query = "";
query += ans;
query += t;
query += t;
query += ans;
query += t;
query += u;
query += ans;
query += t;
query += v;
query += ans;
query += u;
int res = press(query);
if (res == i + 1) ans += t;
if (res == i) ans += u;
if (res == i - 1) ans += v;
}
query = ans + t;
if (press(query) == n) return query;
query = ans + u;
if (press(query) == n) return query;
query = ans + v;
return query;
}
std::string guess_sequence(int N) {
n = N;
int ab = press("AB");
if (ab) {
int a = press("A");
if (a == 1) {
if (n == 1) return "A";
return solve("A", "B", "X", "Y");
}
else {
if (n == 1) return "B";
return solve("B", "A", "X", "Y");
}
}
else {
int x = press("X");
if (x == 1) {
if (n == 1) return "X";
return solve("X", "A", "B", "Y");
}
else {
if (n == 1) return "Y";
return solve("Y", "A", "B", "X");
}
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |