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 <set>
#include <vector>
using namespace std;
int press(string s);
string guess_sequence(int N) {
string ans;
int ab = press("AB");
if (ab == 0) {
int x = press("X");
if (x == 0)
ans += "Y";
else
ans += "X";
} else {
int a = press("A");
if (a == 0)
ans += "B";
else
ans += "A";
}
set<char> s = {'A', 'B', 'X', 'Y'};
s.erase(ans[0]);
vector<char> sv(s.begin(), s.end());
for (int i = 2; i < N; ++i) {
string a(ans), b(ans);
a.push_back(sv[0]);
b.push_back(sv[1]);
string a1(a), a2(a), a3(a);
a1.push_back(sv[0]);
a2.push_back(sv[1]);
a3.push_back(sv[2]);
int q = press(a1 + a2 + a3 + b);
if (q == i + 1)
ans.push_back(sv[0]);
if (q == i)
ans.push_back(sv[1]);
if (q == i - 1)
ans.push_back(sv[2]);
}
string a(ans), b(ans);
a.push_back(sv[0]);
int qa = press(a);
if (qa == N)
return a;
b.push_back(sv[1]);
int qb = press(b);
if (qb == N)
return b;
ans.push_back(sv[2]);
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |