이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
#define vi vector<int>
#define pb push_back
using namespace std;
const int MAXN = 2e5 + 50;
char c[3];
string guess_sequence(int N) {
string p = "";
int val = press("AB");
if (val == 2) {
p = "AB";
c[0] = 'B', c[1] = 'X', c[2] = 'Y';
} else if (val == 1) {
val = press("A");
if (val == 1) {
p = "A";
c[0] = 'B', c[1] = 'X', c[2] = 'Y';
} else {
p = "B";
c[0] = 'A', c[1] = 'X', c[2] = 'Y';
}
} else {
val = press("X");
if (val == 1) {
p = "X";
c[0] = 'A', c[1] = 'B', c[2] = 'Y';
} else {
p = "Y";
c[0] = 'A', c[1] = 'B', c[2] = 'X';
}
}
if (p.size() == N)
return p;
while (p.size() < N - 1) {
string tmp = p + c[0] + c[0] + p + c[0] + c[1] + p + c[0] + c[2] + p + c[1];
val = press(tmp);
if (val == p.size() + 2)
p += c[0];
else if (val == p.size() + 1)
p += c[1];
else
p += c[2];
}
if (press(p + c[0]) == N)
return p + c[0];
else if (press(p + c[1]) == N)
return p + c[1];
return p + c[2];
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
34 | if (p.size() == N)
| ~~~~~~~~~^~~~
combo.cpp:36:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
36 | while (p.size() < N - 1) {
| ~~~~~~~~~^~~~~~~
combo.cpp:39:11: 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 (val == p.size() + 2)
| ~~~~^~~~~~~~~~~~~~~
combo.cpp:41:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
41 | else if (val == p.size() + 1)
| ~~~~^~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |