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