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;
std::string guess_sequence(int N) {
string S = "";
if (press("AB") == 1) {
if (press("A") == 1) {
S = "A";
} else {
S = "B";
}
} else {
if (press("X") == 1) {
S = "X";
} else {
S = "Y";
}
}
if (N == 1) return S;
vector < char > pos = {'A', 'B', 'X', 'Y'};
for (int i = 0; i < 4; ++i) {
if (S[0] == pos[i]) {
pos.erase(pos.begin() + i);
break;
}
}
for (int i = 1; i < N - 1; ++i) {
string Q = S + pos[0] + S + pos[1] + pos[0] + S + pos[1] + pos[1] + S + pos[1] + pos[2];
int coins = press(Q);
if (coins == i) {
S += pos[2];
} else if (coins == (i + 1)) {
S += pos[0];
} else {
S += pos[1];
}
}
if (press(S + pos[0] + S + pos[1]) == N) {
if (press(S + pos[0]) == N) {
S += pos[0];
} else {
S += pos[1];
}
} else {
S += pos[2];
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |