이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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.push_back('A'), idx = 0;
else s.push_back('B'), idx = 1;
}
else {
if (press("XY") >= 1) {
if (press("X") >= 1) s.push_back('X'), idx = 2;
else s.push_back('Y'), idx = 3;
}
}
for (int i = 0; i <= 3; i++) {
if (idx == i) continue;
element[pos++] = key[i];
}
int cur = s.size();
while (cur <= N - 2) {
string p = s + element[0] + element[0] + p + element[0] + element[1] + p + 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[0];
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];
}
cur = s.size();
}
if (s.size() < N) {
if (press(s + element[0]) == N) s.push_back(element[0]);
else if (press(s + element[1]) == N) s.push_back(element[1]);
else s.push_back(element[2]);
}
return s;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
33 | if (cnt == s.size()) {
| ~~~~^~~~~~~~~~~
combo.cpp:36:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | else if (cnt == s.size()+1) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:39:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
39 | if (cnt == s.size()) s = s + element[0] + element[2];
| ~~~~^~~~~~~~~~~
combo.cpp:40:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | else if (cnt == s.size()+1) s = s + element[1] + element[0];
| ~~~~^~~~~~~~~~~~~
combo.cpp:43:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | else if (cnt == s.size()+2) {
| ~~~~^~~~~~~~~~~~~
combo.cpp:46:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
46 | if (cnt == s.size()) s = s + element[1] + element[0];
| ~~~~^~~~~~~~~~~
combo.cpp:47:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
47 | else if (cnt == s.size()+1) s = s + element[0] + element[0];
| ~~~~^~~~~~~~~~~~~
combo.cpp:53:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
53 | if (s.size() < N) {
| ~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |