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 BUTTONS = "ABXY";
int first_button = (press("AB") == 1) ? ((press("A") == 1) ? 0 : 1) : ((press("X") == 1) ? 2 : 3);
swap(BUTTONS[3], BUTTONS[first_button]);
string res(1, BUTTONS[3]);
for(int i = 2; i < N; ++i) {
string ask = res;
ask.push_back(BUTTONS[0]);
for(int j = 0; j < 3; ++j) {
for(char ch : res) {
ask.push_back(ch);
}
ask.push_back(BUTTONS[1]);
ask.push_back(BUTTONS[j]);
}
int o = press(ask);
if(o == i) {
res.push_back(BUTTONS[0]);
}
else if(o == i + 1) {
res.push_back(BUTTONS[1]);
}
else {
res.push_back(BUTTONS[2]);
}
}
if(N > 1) {
int last = 0;
for(int ch = 1; ch < 3; ++ch) {
string ask = res;
ask.push_back(BUTTONS[ch]);
if(press(ask) == N) {
last = ch;
break;
}
}
res.push_back(BUTTONS[last]);
}
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |