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;
char key[] = { 'A','B','X','Y' };
string guess_sequence(int N) {
string s = "";
char element[3];
int pos = 0;
int idx = 0;
if (press("AB") >= 1) {
if (press("A") >= 1) s = "A", idx = 0;
else s = "B", idx = 1;
}
else {
if (press("XY") >= 1) {
if (press("X") >= 1) s="X", idx = 2;
else s="Y", idx = 3;
}
}
for (int i = 0; i <= 3; i++) {
if (idx == i) continue;
element[pos++] = key[i];
}
while ((int)s.size() <= N - 2) {
string p = s + element[0] + element[0] + s + element[0] + element[1] + s + element[1] + element[0];
int cnt = press(p);
if (cnt == s.size()) {
s += element[2];
}
else if (cnt == s.size()+1) {
p = s + element[1] + element[2];
cnt = press(p);
if (cnt == s.size()) s = s + element[0] + element[2];
else if (cnt == s.size()+1) s = s + element[1] + element[1];
else s = s + element[1] + element[2];
}
else if (cnt == s.size()+2) {
p = s + element[0] + element[1];
cnt = press(p);
if (cnt == s.size()) s = s + element[1] + element[0];
else if (cnt == s.size()+1) s = s + element[0] + element[0];
else s = s + element[0] + element[1];
}
}
if (s.size()!=N) {
if (press(s + element[0]) == s.size()+1) s.push_back(element[0]);
else if (press(s + element[1]) == s.size()+1) s.push_back(element[1]);
else s.push_back(element[2]);
}
return s;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:32:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
32 | if (cnt == s.size()) {
| ~~~~^~~~~~~~~~~
combo.cpp:35:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
35 | else if (cnt == s.size()+1) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:38:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | if (cnt == s.size()) s = s + element[0] + element[2];
| ~~~~^~~~~~~~~~~
combo.cpp:39:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | else if (cnt == s.size()+1) s = s + element[1] + element[1];
| ~~~~^~~~~~~~~~~~~
combo.cpp:42:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
42 | else if (cnt == s.size()+2) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:45:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
45 | if (cnt == s.size()) s = s + element[1] + element[0];
| ~~~~^~~~~~~~~~~
combo.cpp:46:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | else if (cnt == s.size()+1) s = s + element[0] + element[0];
| ~~~~^~~~~~~~~~~~~
combo.cpp:51:14: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
51 | if (s.size()!=N) {
| ~~~~~~~~^~~
combo.cpp:52:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
52 | if (press(s + element[0]) == s.size()+1) s.push_back(element[0]);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:53:34: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | else if (press(s + element[1]) == s.size()+1) s.push_back(element[1]);
| ~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |