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) {
char start = '?';
if (press("AB")) {
if (press("A")) start='A';
else start='B';
}
else {
if (press("X")) start='X';
else start='Y';
}
if (N == 1) return {start};
vector<char> trans;
for (char i: {'A', 'B', 'X', 'Y'}) if (i != start) trans.push_back(i);
string res = {start};
for (int i = 1; i<N-1; i++) {
string p = "";
p.append(res);
p.push_back(trans[0]);
p.push_back(trans[0]);
p.append(res);
p.push_back(trans[0]);
p.push_back(trans[1]);
p.append(res);
p.push_back(trans[0]);
p.push_back(trans[2]);
p.append(res);
p.push_back(trans[1]);
int coins = press(p);
if (coins == (int)res.size()) {
res.push_back(trans[2]);
}
if (coins == (int)res.size()+1) {
res.push_back(trans[1]);
}
if (coins == (int)res.size()+2) {
res.push_back(trans[0]);
}
}
// assert((int)res.size() == N-1);
// assert(press(res) == (int)res.size());
string p = "";
p.append(res);
p.push_back(trans[0]);
if (press(p) == N) {
res.push_back(trans[0]);
} else {
p.pop_back();
p.push_back(trans[1]);
if (press(p) == N) {
res.push_back(trans[1]);
}
else res.push_back(trans[2]);
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |