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 = "";
string s = "AB";
vector<char> poss;
int x = press(s);
if (x >= 1) {
if (x == 2) {
ans += 'A';
poss = {'B', 'X', 'Y'};
}
else {
s = "A";
x = press(s);
if (x) {
ans += 'A';
poss = {'B', 'X', 'Y'};
}
else {
ans += 'B';
poss = {'A', 'X', 'Y'};
}
}
}
else {
s = "X";
x = press(s);
if (x) {
ans += 'X';
poss = {'A', 'B', 'Y'};
}
else {
ans += 'Y';
poss = {'A', 'B', 'X'};
}
}
for (int i = 1; i < N-1; i++) {
string s = ans+poss[0];
s += ans+poss[1]+poss[0];
s += ans+poss[1]+poss[1];
s += ans+poss[1]+poss[2];
x = press(s);
if (x == (int)ans.size()+1)
ans += poss[0];
else if (x == (int)ans.size()+2)
ans += poss[1];
else
ans += poss[2];
}
if (N >= 2) {
string s = ans+poss[0];
x = press(s);
if (x == N)
ans = s;
else {
s = ans+poss[1];
x = press(s);
if (x == N)
ans = s;
else
ans += poss[2];
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |