이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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;
}
컴파일 시 표준 에러 (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... |