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>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
using namespace std;
using i64 = long long;
using d64 = long double;
using pi = pair<int, int>;
using pli = pair<i64, i64>;
using ti = tuple<int, int, int>;
using tli = tuple<i64, i64, i64>;
#define iterall(cont) cont.begin(), cont.end()
#define prec(n) setprecision(n) << fixed
int N;
string guess_sequence(int n) {
N = n;
string S;
if (press("AB")) {
if (press("A"))
S += 'A';
else
S += 'B';
} else {
if (press("X"))
S += 'X';
else
S += 'Y';
}
set<char> st = {'A', 'B', 'X', 'Y'};
st.erase(S[0]);
vector<char> vc;
copy(iterall(st), back_inserter(vc));
while (S.size() < N - 1) {
auto x = press(S + vc[0] + vc[1] + S + vc[0] + vc[2] + S + vc[0] + vc[0] + S + vc[1]) - S.size();
if (x == 2)
S += vc[0];
else if (x == 1)
S += vc[1];
else
S += vc[2];
}
if (S.size() < N) {
if (press(S + vc[0] + S + vc[1]) - S.size()) {
if (press(S + vc[0]) - S.size()) S += vc[0];
else S += vc[1];
} else {
S += vc[2];
}
}
return S;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:44:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
44 | while (S.size() < N - 1) {
| ~~~~~~~~~^~~~~~~
combo.cpp:54:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
54 | if (S.size() < N) {
| ~~~~~~~~~^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |