# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
497242 | pakhomovee | Combo (IOI18_combo) | C++17 | 28 ms | 552 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"
#include <vector>
#include <algorithm>
#include <cassert>
using namespace std;
int press(string p);
string guess_sequence(int N) {
vector<char> v = { 'A', 'B', 'X', 'Y' };
string res;
for (int i = 0; i < 3; ++i) {
string curr;
curr += v[i];
if (press(curr)) {
res += v[i];
break;
}
}
if (res.size() == 0) {
res += 'Y';
}
v.erase(find(v.begin(), v.end(), res[0]));
int ptr = 1;
while (ptr + 1 < N) {
string query = res;
query += v[0];
query += res;
query += v[1];
query += v[0];
query += res;
query += v[1];
query += v[1];
query += res;
query += v[1];
query += v[2];
assert(query.size() <= N * 4);
int c = press(query);
if (c == ptr) {
res += v[2];
} else if (c == ptr + 1) {
res += v[0];
} else {
res += v[1];
}
++ptr;
}
if (ptr < N) {
for (int i = 0; i < 2; ++i) {
string curr = res;
curr += v[i];
if (press(curr) == N) {
res += v[i];
break;
}
}
if (res.size() < N) {
res += v[2];
}
}
v = { 'A', 'B', 'X', 'Y' };
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |