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 = "";
char ot[3];
string ans;
if(press("A")==1)
ans="A",ot[0]='B',ot[1]='X',ot[2]='Y';
else if(press("B")==1)
ans="B",ot[0]='A',ot[1]='X',ot[2]='Y';
else if(press("X")==1)
ans="X",ot[0]='B',ot[1]='A',ot[2]='Y';
else if(press("Y")==1)
ans="Y",ot[0]='B',ot[1]='X',ot[2]='A';
//int coins = press(p);
string S;
if(N==1) return ans;
for (int i = 2; i <N; ++i) {
S = ans+ot[0]+ans+ot[1]+ot[0]+ans+ot[1]+ot[1]+ans+ot[1]+ot[2];
//cout<<S<<' ';
if(press(S)==i-1) ans+=ot[2];
else if(press(S)==i) ans+=ot[0];
else ans+=ot[1];
//cout<<ans<<'\n';
}
if(press(ans+ot[0])==N) ans+=ot[0];
else if( press(ans+ot[1])==N) ans+=ot[1];
else ans+=ot[2];
return ans;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:67: warning: 'ot[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
20 | S = ans+ot[0]+ans+ot[1]+ot[0]+ans+ot[1]+ot[1]+ans+ot[1]+ot[2];
| ^
combo.cpp:28:24: warning: 'ot[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
28 | else if( press(ans+ot[1])==N) ans+=ot[1];
| ^
combo.cpp:27:18: warning: 'ot[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
27 | if(press(ans+ot[0])==N) ans+=ot[0];
| ^
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |