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;
std::string guess_sequence(int N) {
const string rop[4] = {"A","B","X","Y"};
int ena = press("AB");
int of = 0;
if(ena >= 1) {
int enb = press("A");
if(enb) {
of = 0;
} else {
of = 1;
}
} else {
int enb = press("X");
if(enb) {
of = 2;
} else {
of = 3;
}
}
string op[4] = {rop[(of+1)%4],rop[(of+2)%4],rop[(of+3)%4],rop[of]};
char cop[4] = {op[0][0],op[1][0],op[2][0],op[3][0]};
string S = op[3];
while(S.size() < N-1) {
int val = press(S+op[0]+S+op[1]+op[0]+S+op[1]+op[1]+S+op[1]+op[2]);
if(val == S.size()+1) {
S.push_back(cop[0]);
} else if(val == S.size()+2) {
S.push_back(cop[1]);
} else {
S.push_back(cop[2]);
}
}
if(S.size() == N-1) {
if(press(S+op[0]) == N) {
S.push_back(cop[0]);
} else if(press(S+op[1]) == N) {
S.push_back(cop[1]);
} else {
S.push_back(cop[2]);
}
}
return S;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:27:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
27 | while(S.size() < N-1) {
| ~~~~~~~~~^~~~~
combo.cpp:29:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
29 | if(val == S.size()+1) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:31:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
31 | } else if(val == S.size()+2) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:37:14: 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... |