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>
#define fore(i, b, e) for (int i = b; i < (int)e; ++i)
using namespace std;
std::string guess_sequence(int N) {
string pref;
int val = press("AB");
if (val == 0) {
val = press("X");
if (val == 0) pref = "Y";
else pref = "X";
}
else {
val = press("A");
if (val == 0) pref = "B";
else pref = "A";
}
string extra = "ABXY";
while (extra[0] != pref[0]) next_permutation(extra.begin(), extra.end());
//assert(extra[0] == pref[0]);
fore(i, 1, N) {
string test = pref + extra.substr(1,1);
fore(i, 1, 4) {
test += pref;
test += extra.substr(2,1);
test += extra[i];
}
if ((int)test.size() > 4*N) break;
//cerr << "test: " << test << endl;
val = press(test);
if (val == i) pref += extra[3];
if (val == i+1) pref += extra[1];
if (val == i+2) pref += extra[2];
}
assert((int)pref.size() == N-1);
val = press(pref + extra.substr(1,1) + pref + extra.substr(2,1));
if (val == N) {
val = press(pref + extra.substr(1,1));
if (val == N) pref += extra[1];
else pref += extra[2];
}
else {
pref += extra[3];
}
//cerr << "res = " << pref << endl;
return pref;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |