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 s);
string guess_sequence(int n){
string ans = "";
string s[4] = {"A", "B", "X", "Y"};
int sum = press(s[0]+s[1]);
if(sum == 0){
sum = press(s[2]);
if(sum == 1) ans += s[2], swap(s[2], s[3]);
else ans += s[3];
}
else if(sum == 1){
sum = press(s[0]);
if(sum == 1) ans += s[0], swap(s[0], s[3]);
else ans += s[1], swap(s[1], s[3]);
}
else{
ans += s[0]+s[1];
swap(s[0], s[3]);
}
while((int)ans.length() != n){
int m = ans.length();
if(m+1 == n){
sum = press(ans+s[0] + ans+s[1]);
if(sum != n) ans += s[2];
else{
sum = press(ans+s[0]);
if(sum == n) ans += s[0];
else ans += s[1];
}
}
else{
sum = press(ans+s[0] + ans+s[1]+s[0] + ans+s[1]+s[1] + ans+s[1]+s[2]);
if(sum == m+1) ans += s[0];
else if(sum == m+2) ans += s[1];
else ans += s[2];
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |