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) {
string choices = "ABXY";
string ret = "";
int pos = -1;
if (press(string(1, choices[0]) + string(1, choices[1]))) {
pos = press(string(1, choices[1]));
} else {
pos = 2 + press(string(1, choices[3]));
}
ret.push_back(choices[pos]);
choices.erase(pos, 1);
for (int i = 1; i < N; ++i) {
if (i == N - 1) {
pos = 2;
for (int j : {0, 1}) {
if (press(ret + choices[j]) == N){
pos = j; break;
}
}
ret.push_back(choices[pos]);
break;
}
string ask = "";
ret.push_back(choices[0]);
for (int j : {0, 1, 2}) {
ret.push_back(choices[j]);
ask += ret;
ret.pop_back();
}
ret.pop_back(); ret.push_back(choices[1]);
ask += ret; ret.pop_back();
int len = press(ask);
if (len == i + 2) {
ret.push_back(choices[0]);
} else if (len == i + 1) {
ret.push_back(choices[1]);
} else {
ret.push_back(choices[2]);
}
}
return ret;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |