# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
638640 | rockoana | Combo (IOI18_combo) | C++17 | 37 ms | 588 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 "combo.h"
using namespace std;
std::string guess_sequence(int N) {
int n = N;
string res = "";
string lft = "";
// first letter
string q = "AB";
int c = press(q);
if (c >= 1) {
q = "B";
c = press(q);
if (c) {
res += 'B';
lft = "AXY";
} else {
res += 'A';
lft = "BXY";
}
} else {
q = "X";
c = press(q);
if (c) {
res += 'X';
lft = "ABY";
} else {
res += 'Y';
lft = "ABX";
}
}
if (n == 1) {
return res;
}
// next letters
while (res.size() < n - 1) {
q = res + lft[0];
q += res + lft[1] + lft[1];
q += res + lft[1] + lft[0];
q += res + lft[1] + lft[2];
c = press(q);
if (c == res.size()) {
res += lft[2];
} else if (c == res.size() + 1) {
res += lft[0];
} else {
res += lft[1];
}
}
// last letter
q = res + lft[0];
q += res + lft[1];
c = press(q);
if (c == n) {
q = res + lft[0];
c = press(q);
if (c == n) {
res += lft[0];
} else {
res += lft[1];
}
} else {
res += lft[2];
}
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |