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 "combo.h"
using namespace std;
string guess_sequence(int n)
{
string a, c, d, e, f, g, h;
int b = press("AB"), x;
if(b >= 1)
{
b = press("A");
if(b == 1) a = "A";
else a = "B";
}
else
{
b = press("X");
if(b == 1) a = "X";
else a = "Y";
}
if(n == 1) return a;
if(a == "A") c = f = "B", d = g = "X", e = h = "Y";
if(a == "B") c = f = "X", d = g = "Y", e = h = "A";
if(a == "X") c = f = "Y", d = g = "A", e = h = "B";
if(a == "Y") c = f = "A", d = g = "B", e = h = "X";
x = 1;
for(int i=1;i<n-1;i++)
{
b = press(a+c+f+a+c+g+a+d+f);
if(b == a.size()+c.size()) e = d+h, d = d+g, c = c+h;
else if(b == a.size()+c.size()+1) e = d+f, d = c+g, c = c+f;
else a+=e, c = f, d = g, e = h;
}
if(a.size() == n) return a;
if(press(a+c+a+d)!=n) return a+e;
if(press(a+c)!=n) return a+d;
return a+c;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:28:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
28 | if(b == a.size()+c.size()) e = d+h, d = d+g, c = c+h;
| ~~^~~~~~~~~~~~~~~~~~~~
combo.cpp:29:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | else if(b == a.size()+c.size()+1) e = d+f, d = c+g, c = c+f;
| ~~^~~~~~~~~~~~~~~~~~~~~~
combo.cpp:32:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
32 | if(a.size() == n) return a;
| ~~~~~~~~~^~~~
combo.cpp:6:23: warning: variable 'x' set but not used [-Wunused-but-set-variable]
6 | int b = press("AB"), x;
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |