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>
#include "combo.h"
using namespace std;
string guess_sequence(int N){
string p="";
vector<string> ch;
if(press("AB")>0){
if(press("A")==1) p="A",ch={"B","X","Y"};
else p="B",ch={"A","X","Y"};
}else{
if(press("X")==1) p="X",ch={"A","B","Y"};
else p="Y",ch={"A","B","X"};
}
if(N==1) return p;
string P=p;
for(int i=0;i<N-2;++i){
string nstr=p+ch[0]+ch[0]+p+ch[0]+ch[1]+p+ch[0]+ch[2]+p+ch[1];
int k=press(nstr);
if(k==p.size()+1){
p+=ch[1];
}else if(k==p.size()+2){
p+=ch[0];
}else{
p+=ch[2];
}
}
if(press(p+ch[0]+p+ch[1])==N){
if(press(p+ch[0])==N) return p+ch[0];
else return p+ch[1];
}else{
return p+ch[2];
}
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | if(k==p.size()+1){
| ~^~~~~~~~~~~~
combo.cpp:22:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
22 | }else if(k==p.size()+2){
| ~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |