This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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;
}
Compilation message (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... |