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>
#include<combo.h>
using namespace std;
string guess_sequence(int N)
{
string mo = "";
int first = press("AB"), second;
if(first) {
second = press("A");
if(second) mo = "A";
else mo = "B";
}
else {
second = press("X");
if(second) mo = "X";
else mo = "Y";
}
if(N == 1) return mo;
string elements = "ABXY";
vector<char> notFirst;
for(char c : elements) {
if(c != mo[0]) notFirst.push_back(c);
}
for(int i = 1; i < N - 1; i++) {
string temp = "";
temp += mo + notFirst[0] + notFirst[0];
temp += mo + notFirst[0] + notFirst[1];
temp += mo + notFirst[0] + notFirst[2];
temp += mo + notFirst[1];
int ans = press(temp);
if(ans == i) {
mo += notFirst[2];
}
else if(ans == i+1) {
mo += notFirst[1];
}
else {
mo += notFirst[0];
}
}
bool b = false;
for(int i = 0; i < 2; i++) {
int temp = press(mo + notFirst[i]);
if(temp == N) {
b = true;
mo += notFirst[i];
break;
}
}
if(!b) mo += notFirst[2];
return mo;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |