이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
char first = press("AB") == 0? "YX"[press("X")]:
"BA"[press("A")];
char a, b, c;
if(first == 'A') a = 'B', b = 'X', c = 'Y';
if(first == 'B') a = 'A', b = 'X', c = 'Y';
if(first == 'X') a = 'A', b = 'B', c = 'Y';
if(first == 'Y') a = 'A', b = 'B', c = 'X';
std::string S(1, first);
while(S.length() + 2 <= N) {
int coins = press(S + a + a + S + a + b + S + b + a) - S.length();
if (coins == 0) {
S += c;
} else if (coins == 1) {
coins = press(S + b + c) - S.length();
if (coins == 0) {
S += a, S += c;
} else if (coins == 1) {
S += b, S += b;
} else if (coins == 2) {
S += b, S += c;
}
} else if (coins == 2) {
coins = press(S + a + b) - S.length();
if (coins == 0) {
S += b, S += a;
} else if (coins == 1) {
S += a, S += a;
} else if (coins == 2) {
S += a, S += b;
}
}
}
if (S.length() < N) {
if (press(S + a) - S.length() == 1) {
S += a;
} else if(press(S + b) - S.length() == 1) {
S += b;
} else {
S += c;
}
}
return S;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:17:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
17 | while(S.length() + 2 <= N) {
| ~~~~~~~~~~~~~~~^~~~
combo.cpp:42:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
42 | if (S.length() < N) {
| ~~~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |