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(ans.length() != n){
int m = ans.length();
sum = press(ans+s[0] + ans+s[1]+s[0] + ans+s[1]+s[1] + ans+s[1]+s[2]);
if(sum == m+1){
if(m+1 == n){
sum = press(ans+s[0]);
if(sum == n) ans += s[0];
else ans += s[1];
}
else ans += s[0];
}
else if(sum == m+2) ans += s[1];
else ans += s[2];
}
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
24 | while(ans.length() != n){
| ~~~~~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |