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){
vector<int> mp = {'A','B','X','Y'};
string s = ""; int p;
int r = press("AB");
if(r == 0){
r = press("X");
if(r == 0){
s += "Y";
p = 3;
}
else{
s += "X";
p = 2;
}
}
else if(r == 1){
r = press("A");
if(r == 0){
s += "B";
p = 1;
}
else{
s += "A";
p = 0;
}
}
else{
p = 0;
s += "A";
}
if(N == 1) return s;
for(int i = 1;i<=N-2;++i){
string cur = "";
for(int j = 0;j<4;++j){
if(j != p){
cur += s; cur += mp[(p+1)%4];
cur += mp[j];
}
}
cur += s; cur += mp[(p+2)%4];
int r = press(cur);
if(r == i){
s += mp[(p+3)%4];
}
else if(r == i+1){
s += mp[(p+2)%4];
}
else{
s += mp[(p+1)%4];
}
}
string cur = ""; cur += s; cur += mp[(p+1)%4];
r = press(cur);
if(r == N) return cur;
string newcur = ""; newcur += s; newcur += mp[(p+2)%4];
r = press(newcur);
if(r == N) return newcur;
s += mp[(p+3)%4];
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |