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;
string guess_sequence(int n) {
string chars[] = {"A", "B", "X", "Y"};
int first = 0;
if (press("AB") > 0) {
first = press("B");
} else {
first = 2 + press("Y");
}
string r = chars[first];
if (n == 1)
return r;
vector<int> ids;
for (int j = 0; j < 4; ++j) {
if (j == first) continue;
ids.push_back(j);
}
for (int i = 0; i < n - 2; ++i) {
string f = r + chars[ids[0]];
string s = r + chars[ids[1]];
string query = (f + chars[ids[0]]) + (f + chars[ids[1]]) + (f + chars[ids[2]]) + s;
int c = press(query);
if (c == (int) f.size() + 1) r += chars[ids[0]]; else
if (c == (int) s.size()) r += chars[ids[1]]; else
r += chars[ids[2]];
}
if (press(r + chars[ids[0]]) == n) r += chars[ids[0]]; else
if (press(r + chars[ids[1]]) == n) r += chars[ids[1]]; else
r += chars[ids[2]];
return r;
}
/*
Usage:
std::string p = "";
for (int i = 0; i < 4 * N; ++i) {
p += 'A';
}
int coins = press(p);
std::string S = "";
for (int i = 0; i < N; ++i) {
S += 'A';
}
return S;
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |