# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
170240 | socho | Combo (IOI18_combo) | C++14 | 43 ms | 616 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 "bits/stdc++.h"
#include "combo.h"
using namespace std;
int press(string s);
string guess_sequence(int N) {
int xy = press("XY");
char first;
string oth;
if (xy > 0) {
// x or y
int x = press("X");
if (x > 0) {
first = 'X';
oth = "ABY";
}
else {
first = 'Y';
oth = "ABX";
}
}
else {
// a or b
int a = press("A");
if (a > 0) {
first = 'A';
oth = "BXY";
}
else {
first = 'B';
oth = "AXY";
}
}
string found;
found += first;
if (found.size() == N) return found;
for (int i=1; i<N-1; i++) {
// to find this i try a few things
int curr = i;
string qry = "";
qry += (found + oth[0]); // if my res is curr+1, then it must be oth[0] next
qry += (found + oth[1] + oth[0]);
qry += (found + oth[1] + oth[1]);
qry += (found + oth[1] + oth[2]); // and curr+2 means oth[1]
// so curr means oth[2]
// cout << qry << endl;
int res = press(qry);
if (res == curr) {
found += oth[2];
}
else if (res > curr + 1) {
found += oth[1];
}
else {
found += oth[0];
}
}
string oth0 = found + oth[0];
if (press(oth0) == N) {
return oth0;
}
string oth1 = found + oth[1];
if (press(oth1) == N) {
return oth1;
}
found = found + oth[2];
return found;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |