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>
using namespace std;
int press(std::string p);
string guess_sequence(int N){
if(N == 1){
if(press("A")) return "A";
if(press("B")) return "B";
if(press("X")) return "X";
return "Y";
}
vector<string> t = {"A", "B", "X", "Y"};
string s;
if(press("AB")){
if(press("A")) s = "A";
else s = "B";
} else{
if(press("X")) s = "X";
else s = "Y";
}
for(string &c: t){
if(c == s){
swap(c, t.back());
break;
}
}
t.pop_back();
for(int i = 2; i < N; i++){
int x = press(s + t[0] + t[0] + s + t[0] + t[1] + s + t[0] + t[2] + s + t[1]);
s += t[2 - (x - i + 1)];
}
if(press(s + t[0]) == N) s += t[0];
else if(press(s + t[1])) s += t[1];
else s += t[2];
cout << s << endl;
return s;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |