이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N) {
string ret;
int f1 = press("AB");
if (f1 == 0) {
f1 = press("X");
if (f1 == 1) ret += "X";
else ret += "Y";
}
else if (f1 == 1) {
f1 = press("B");
if (f1 == 1) ret = "B";
else ret = "A";
}
else ret = "AB";
vector<string> possible = {"A", "B", "X", "Y"};
possible.erase(std::find(possible.begin(), possible.end(), string(1, ret[0])));
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
while (ret.size() != N) {
shuffle(possible.begin(), possible.end(), rng);
int news = press(ret + possible[0] + ret + possible[1]);
if (news == ret.size()) {
ret += possible.back();
}
else {
news = press(ret + possible[0]);
if (news == ret.size()) ret += possible[1];
else ret += possible[0];
}
}
return ret;
}
컴파일 시 표준 에러 (stderr) 메시지
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:26:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
26 | while (ret.size() != N) {
| ~~~~~~~~~~~^~~~
combo.cpp:30:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
30 | if (news == ret.size()) {
| ~~~~~^~~~~~~~~~~~~
combo.cpp:36:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
36 | if (news == ret.size()) ret += possible[1];
| ~~~~~^~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |