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 ans = "";
vector<string> pos;
int x = press("XY"); //
if(x == 2) {ans = "XY"; pos = {"Y", "A", "B"};}
else if(x == 1){
x = press("X"); //
if(x) {ans = "X"; pos = {"Y", "A", "B"};}
else {ans = "Y"; pos = {"X", "A", "B"};}
}else{
x = press("A"); //
if(x) {ans = "A"; pos = {"Y", "X", "B"};}
else {ans = "B"; pos = {"Y", "A", "X"};}
}
while(ans.size() + 2 <= N){
ans += pos[0];
ans += pos[1];
string ss = ans;
ans.pop_back();
ans += pos[0];
ss += ans;
ans.pop_back();
ans.pop_back();
ans += pos[1];
ans += pos[1];
ss += ans;
x = press(ss); //
ans.pop_back();
ans.pop_back();
if(x == ans.size() + 2){
ans += pos[0];
ans += pos[0];
x = press(ans); //
ans.pop_back();
ans.pop_back();
if(x == ans.size() + 1){
ans += pos[0];
ans += pos[1];
}else if(x == ans.size()){
ans += pos[1];
ans += pos[1];
}else{
ans += pos[0];
ans += pos[0];
}
}else if(x == ans.size() + 1){
ans += pos[1];
ans += pos[2];
x = press(ans); //
ans.pop_back();
ans.pop_back();
if(x == ans.size() + 1){
ans += pos[1];
ans += pos[0];
}else if(x == ans.size()){
ans += pos[0];
ans += pos[2];
}else{
ans += pos[1];
ans += pos[2];
}
}else ans += pos[2];
}
if(ans.size() == N) return ans;
else{
ans += pos[0];
x = press(ans); //
if(x == N) return ans;
else{
ans.pop_back();
ans += pos[1];
x = press(ans); //
if(x == N) return ans;
else{
ans.pop_back();
ans += pos[2];
return ans;
}
}
}
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
20 | while(ans.size() + 2 <= N){
| ~~~~~~~~~~~~~~~^~~~
combo.cpp:35:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | if(x == ans.size() + 2){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:41:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | if(x == ans.size() + 1){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:44:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | }else if(x == ans.size()){
| ~~^~~~~~~~~~~~~
combo.cpp:51:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
51 | }else if(x == ans.size() + 1){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:57:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | if(x == ans.size() + 1){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:60:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
60 | }else if(x == ans.size()){
| ~~^~~~~~~~~~~~~
combo.cpp:69:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
69 | if(ans.size() == N) return ans;
| ~~~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |