# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
154065 | nthoang | Combo (IOI18_combo) | C++11 | 0 ms | 0 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>
#ifndef LOCAL
#include "combo.h"
#endif
#ifdef LOCAL
#include "/Users/nth842002/Library/debug.h"
int press(string p) { }
int main() { }
#endif
using namespace std;
const string moves = "ABXY";
string guess_sequence(int n) {
srand(time(0));
string s;
for (int i = 0; i < 3; i++) {
s += moves[i];
if (press(s) == 1) {
break;
}
s.pop_back();
}
if (s.empty()) {
s += moves[3];
}
vector<string> avail(n);
for (int i = 0; i < 4; i++) {
if (moves[i] != s[0]) {
avail[0] += moves[i];
}
}
for (int i = 1; i < n; i++) {
avail[i] = avail[0];
assert((int) avail[i].size() == 3);
random_shuffle(avail[i].begin(), avail[i].end());
}
for (int i = 1; i < n; i++) {
s += avail[i][0];
int t = press(s);
if (t == i - 1) {
s[i - 1] = avail[i - 1][2];
} else if (t == i) {
s[i] = avail[i][1];
}
}
if (press(s) != n) {
s[n - 1] = avail[i][2];
}
assert((int) s.size() == n);
return s;
}
/* Subtask: q <= 2N + 1
string guess_sequence(int n) {
srand(time(0));
string s;
for (int i = 0; i < 3; i++) {
string t;
t += moves[i];
if (press(t) == 1) {
s += moves[i];
break;
}
}
if (s.empty()) {
s += moves[3];
}
string avail;
for (int i = 0; i < 4; i++) {
if (moves[i] != s[0]) {
avail += moves[i];
}
}
for (int i = 1; i < n; i++) {
random_shuffle(avail.begin(), avail.end());
for (int j = 0; j < 2; j++) {
s += avail[j];
if (press(s) == i + 1) {
break;
}
s.pop_back();
}
if (s.length() == i) {
s += avail[2];
}
}
assert((int) s.length() == n);
return s;
}
*/