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 a = 'A' , b = 'B' , x = 'X' , y = 'Y';
p += a ;
p += b;
int coins = press(p);
string S = "";
if(coins){
p = "" ;
p += a ;
coins = press(p);
if(!coins)swap(a , b) , p = " " , p += a ;
}
else {
p = "" ;
p += x ;
coins = press(p);
if(coins)swap(a , x) ;
else swap(y , a) , p = "" , p += a ;
}
S.push_back(a);
int past = 1 ;
while(1){
if(S.size() == N)return S ;
if(S.size() == N - 1){
S += b ;
if(press(S) == N)return S ;
S.pop_back();
S += x ;
if(press(S) == N)return S ;
S.pop_back();
S += y ;
return S ;
}
p = S ;
p += b ;
p += b ;
p += S ;
p += b ;
p += x ;
p += S ;
p += b ;
p += y ;
p += S ;
p += x ;
coins = press(p);
if(coins == past){
S += y ;
}
else {
if(coins - 1 == past)
S += x ;
else S += b ;
}
past ++ ;
}
return S;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | if(S.size() == N)return S ;
| ~~~~~~~~~^~~~
combo.cpp:37:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | if(S.size() == N - 1){
| ~~~~~~~~~^~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |