This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#ifndef COMBO_CPP_INCLUDED
#define COMBO_CPP_INCLUDED
#include "combo.h"
#include <vector>
#include <cassert>
#include <iostream>
#include <random>
std::mt19937 rng(0);
std::string str = "";
int NNN;
std::string guess_sequence(int n) {
NNN = n;
std::vector<std::string> alphabet = {"A", "B", "X", "Y"};
std::string first = "";
if (press("AB")) {
if (press("A")) {
first = "A";
} else {
first = "B";
}
} else {
if (press("X")) {
first = "X";
} else {
first = "Y";
}
}
if (first.empty()) {
first = alphabet.back();
}
if (n == 1) {
return first;
}
int ptr = 0;
while (alphabet[ptr] != first) {
ptr++;
}
alphabet.erase(alphabet.begin() + ptr);
str += first;
for (int i = 1; i + 1 < n; i++) {
std::string ask = str + alphabet[0];
for (int i = 0; i < 3; i++) {
ask += str + alphabet[1] + alphabet[i];
}
assert((int) ask.size() <= 4 * n);
int ret = press(ask);
if (ret == (int) str.size()) {
str += alphabet[2];
} else if (ret == 1 + (int) str.size()) {
str += alphabet[0];
} else {
str += alphabet[1];
}
}
for (int i = 0; i < 2; i++) {
if (press(str + alphabet[i]) == 1 + (int) str.size()) {
str += alphabet[i];
}
}
if ((int) str.size() < n) {
str += alphabet[2];
}
return str;
}
#endif // COMBO_CPP_INCLUDED
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |