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(string p);
// cout << p << '\n';
// int r;
// cin >> r;
// return r;
// }
string guess_sequence(int n){
string s;
if(press("AB")){
if(press("A")) s += 'A';
else s += 'B';
} else {
if(press("X")) s += 'X';
else s += 'Y';
}
if(n == 1) return s;
vector<char> c = {'A', 'B', 'X', 'Y'};
for(int i = 0;i < 4;i++) if(c[i] == s[0]) {
c.erase(c.begin()+i);
break;
}
for(int i = 1;i < n-1;i++){
int r = press(s + c[0] + c[0] + s + c[0] + c[1] + s + c[0] + c[2] + s + c[1]);
if(r == i+2) s += c[0];
else if (r == i+1) s += c[1];
else s += c[2];
}
if(press(s + c[0] + s + c[1]) == n){
if(press(s + c[0]) == n) s += c[0];
else s += c[1];
} else s += c[2];
return s;
}
// int main(){
// guess_sequence(6);
// }
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |