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"
#include "bits/stdc++.h"
using namespace std;
string guess_sequence(int N)
{
string p = "";
string S = "";
int coin;
char rest[3];
coin=press("AB");
if(coin==0)
{
coin=press("Y");
if(coin==1)
{
S+='Y';
//rest={'A','B','X'};
rest[0]='A';
rest[1]='B';
rest[2]='X';
}else{
S+='X';
//rest={'A','B','Y'};
rest[0]='A';
rest[1]='B';
rest[2]='Y';
}
}else{
coin=press("A");
if(coin==1)
{
S+='A';
//rest={'Y','B','X'};
rest[0]='Y';
rest[1]='B';
rest[2]='X';
}else{
S+='B';
//rest={'A','Y','X'};
rest[0]='A';
rest[1]='Y';
rest[2]='X';
}
}
while(S.length()<N-1)
{
p=S+rest[0]+S+rest[1]+rest[1]+S+rest[1]+rest[2]+S+rest[1]+rest[0];
coin=press(p);
if(coin==S.length()+1)
{
S+=rest[0];
}
else if(coin==S.length())
{
S+=rest[2];
}
else{
S+=rest[1];
}
}
if(S.length()==N-1)
{
p=S+rest[0]+S+rest[1];
coin=press(p);
if(coin==S.length())
{
S+=rest[2];
}else{
p=S+rest[0];
coin=press(p);
if(coin==S.length())
{
S+=rest[1];
}else{
S+=rest[0];
}
}
}
return S;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:48:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
48 | while(S.length()<N-1)
| ~~~~~~~~~~^~~~
combo.cpp:52:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | if(coin==S.length()+1)
| ~~~~^~~~~~~~~~~~~~
combo.cpp:56:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
56 | else if(coin==S.length())
| ~~~~^~~~~~~~~~~~
combo.cpp:64:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
64 | if(S.length()==N-1)
| ~~~~~~~~~~^~~~~
combo.cpp:68:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
68 | if(coin==S.length())
| ~~~~^~~~~~~~~~~~
combo.cpp:74:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
74 | if(coin==S.length())
| ~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |