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 <bits/stdc++.h>
#ifndef LOCAL
#include "combo.h"
#endif
#ifdef LOCAL
#include "/Users/nth842002/Library/debug.h"
int press(string p) { }
int main() { }
#endif
using namespace std;
const string moves = "ABXY";
string guess_sequence(int n) {
string s;
if (press("AB")) {
s += (press("A") ? 'A' : 'B');
} else {
s += (press("X") ? 'X' : 'Y');
}
string avail;
for (int i = 0; i < 4; i++) {
if (moves[i] != s[0]) {
avail += moves[i];
}
}
for (int i = 1; i < n - 1; i++) {
string t = s + avail[0];
t += s + avail[1] + avail[0];
t += s + avail[1] + avail[1];
t += s + avail[1] + avail[2];
int c = press(t);
if (c == (int) s.length() + 1) {
s += avail[0];
} else if (c == (int) s.length() + 2) {
s += avail[1];
} else {
s += avail[2];
}
}
if (n > 1) {
for (int i = 0; i < 2; i++) {
s += avail[i];
if (press(s) == n) {
break;
}
s.pop_back();
}
if ((int) s.length() < n) {
s += avail[2];
}
}
return s;
}
/* Subtask: q <= 2N + 1
string guess_sequence(int n) {
srand(time(0));
string s;
for (int i = 0; i < 3; i++) {
string t;
t += moves[i];
if (press(t) == 1) {
s += moves[i];
break;
}
}
if (s.empty()) {
s += moves[3];
}
string avail;
for (int i = 0; i < 4; i++) {
if (moves[i] != s[0]) {
avail += moves[i];
}
}
for (int i = 1; i < n; i++) {
random_shuffle(avail.begin(), avail.end());
for (int j = 0; j < 2; j++) {
s += avail[j];
if (press(s) == i + 1) {
break;
}
s.pop_back();
}
if (s.length() == i) {
s += avail[2];
}
}
assert((int) s.length() == n);
return s;
}
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |