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 <iostream>
#include <string>
#define watch(x) cerr<<#x<<": "<<(x)<<endl
#include "combo.h"
using namespace std;
char getFirst() {
if (press("AB") >= 1) {
return press("A")==1 ? 'A' : 'B';
} else {
return press("X")==1 ? 'X' : 'Y';
}
}
string valid = "ABXY";
string newValid(string s, char first) {
string r;
for (char c : s) {
if (c != first) {
r.push_back(c);
}
}
return r;
}
int sz(string s) {
return s.size();
}
string guess_sequence(int N) {
string p,S;
char first = getFirst();
S.push_back(first);
watch(first);
valid = newValid(valid,first);
watch(valid);
for (int i=2; i<=N; i++) {
if (press(S+valid[0]+S+valid[1]) == sz(S)) {
S.push_back(valid[2]);
} else if (press(S+valid[0]) == sz(S)) {
S.push_back(valid[1]);
} else {
S.push_back(valid[0]);
}
}
watch(S);
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |