이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#pragma GCC optimize("O2")
#pragma GCC target("avx,avx2,fma")
#include "combo.h"
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FOD(i, a, b) for (int i = (a); i >= (b); i--)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define file(name) if (fopen(name".inp", "r")) { freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout); }
using namespace std;
const int MAXN = 2e5 + 5;
string guess_sequence(int N) {
if (N == 1) {
if (press("A")) return "A";
if (press("B")) return "B";
if (press("X")) return "X";
return "Y";
}
string T = "", S = "";
if (press("AB")) {
if (press("A")) T += 'A';
else T += 'B';
} else {
if (press("X")) T += 'X';
else T += 'Y';
}
for (char c : {'A', 'B', 'X', 'Y'}) {
if (c == T[0]) continue;
T += c;
}
S = T[0];
while (S.size() < N - 1) {
string ask = S + T[1] + T[1] + S + T[1] + T[2] + S + T[1] + T[3] + S + T[2];
int p = press(ask);
if (p - 2 == S.size()) S += T[1];
else if (p - 1 == S.size()) S += T[2];
else S += T[3];
}
if (press(S + T[1]) == N) return S + T[1];
else if (press(S + T[2]) == N) return S + T[2];
else return S + T[3];
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:40:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
40 | while (S.size() < N - 1) {
| ~~~~~~~~~^~~~~~~
combo.cpp:43:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
43 | if (p - 2 == S.size()) S += T[1];
| ~~~~~~^~~~~~~~~~~
combo.cpp:44:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
44 | else if (p - 1 == S.size()) S += T[2];
| ~~~~~~^~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |