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 <vector>
std::string guess_sequence(int N) {
std::string S = "";
std::string fc = "";
if (press("AB")) {
if (press("A")) fc = "A";
else fc = "B";
} else {
if (press("X")) fc = "X";
else fc = "Y";
}
S = fc;
std::vector<std::string> oops = {"A", "B", "X", "Y"};
std::vector<std::string> chars;
for (auto &each: oops)
if (each != fc) chars.push_back(each);
for (int n = 2; n < N; ++n) {
std::string p = "";
p += S + chars[0] + S + chars[1] + chars[0] + S + chars[1] + chars[1]
+ S + chars[1] + chars[2];
int ret = press(p);
if (ret == n) S += chars[0];
else if (ret == (n + 1)) S += chars[1];
else S += chars[2];
}
std::string p1 = S; std::string p2 = S;
if (N > 1) {
p1 += chars[0];
p2 += chars[1];
}
if (press(p1) == N) return p1;
else if (press(p2) == N) return p2;
else if (N > 1) return S + chars[2];
else return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |