# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
766872 | jakobrs | Combo (IOI18_combo) | C++17 | 0 ms | 208 KiB |
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 <iostream>
#include <random>
int press(std::string p);
using i64 = int64_t;
std::string guess_sequence(int n) {
std::mt19937 rng(102435324);
char cha = 'A';
char chb = 'B';
char chx = 'X';
char chy = 'Y';
if (press("AB")) {
if (press("A")) {
std::swap(cha, cha);
} else {
std::swap(cha, chb);
}
} else {
if (press("X")) {
std::swap(cha, chx);
} else {
std::swap(cha, chy);
}
}
std::string guess = { cha };
std::string seq;
for (i64 i = 1; i < n; i++) {
if (i == n - 1) {
if (press(guess + chb)) {
guess += chb;
} else if (press(guess + chx)) {
guess += chx;
} else {
guess += chy;
}
} else {
seq.clear();
seq.append(guess);
seq.push_back(chb);
seq.append(guess);
seq.push_back(chx);
seq.push_back(chb);
seq.append(guess);
seq.push_back(chx);
seq.push_back(chx);
seq.append(guess);
seq.push_back(chx);
seq.push_back(chy);
i64 result = press(seq);
if (result == guess.size()) {
guess += chy;
} else if (result == guess.size() + 1) {
guess += chb;
} else {
guess += chx;
}
}
}
return guess;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |