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;
string guess_sequence(int N) {
string ans = "AB";
int res = press(ans);
// cout << "RES1: " << res << '\n';
if (res >= 1) {
ans = "A";
res = press(ans);
if (res == 0)
ans = "B";
} else {
ans = "X";
res = press(ans);
if (res == 0)
ans = "Y";
}
vector <char> c(3);
if (ans[0] == 'A')
c = {'B', 'X', 'Y'};
if (ans[0] == 'B')
c = {'A', 'X', 'Y'};
if (ans[0] == 'X')
c = {'A', 'B', 'Y'};
if (ans[0] == 'Y')
c = {'A', 'B', 'X'};
for (int i = 1; i+1 < N; i++) {
string s = ans;
s.push_back(c[0]);
for (int j = 0; j < 3; j++) {
s.append(ans);
s.push_back(c[1]);
s.push_back(c[j]);
}
// cout << "guess: " << s << '\n';
res = press(s);
// cout << "result: " << res << '\n';
if (res == i+1)
ans.push_back(c[0]);
else if (res == i+2)
ans.push_back(c[1]);
else
ans.push_back(c[2]);
}
if (N >= 2) {
ans.push_back(c[0]);
res = press(ans);
if (res == N) {
return ans;
}
ans.pop_back();
ans.push_back(c[1]);
res = press(ans);
if (res == N)
return ans;
ans.back() = c[2];
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |