# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
84141 | lovemathboy | Combo (IOI18_combo) | C++14 | 292 ms | 620 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 <bits/stdc++.h>
using namespace std;
char all[] = {'A', 'B', 'X', 'Y'};
string guess_sequence(int n) {
string p = "";
string ans = "";
for (int i = 0; i < 4*n; i++) {
if (i < 2*n) p += 'A';
else p += 'B';
}
char first = 'A';
int res = press(p);
p = "";
if (res > 0) {
for (int i = 0; i < 4*n; i++) {
p += 'A';
}
if (press(p) > 0) first = 'A';
else first = 'B';
}
else {
for (int i = 0; i < 4*n; i++) {
p += 'X';
}
if (press(p) > 0) first = 'X';
else first = 'Y';
}
ans += first;
char pos[3]; int cnt = 0;
for (int i = 0; i < 4; i++) {
if (all[i] == first) continue;
pos[cnt] = all[i]; cnt++;
}
for (int i = 1; i < n-1; i++) {
p = ans + pos[0];
for (int j = 0; j < 3; j++) {
p += ans + pos[1] + pos[j];
}
while (p.length() < 4*n) p += first;
int res = press(p);
if (res == ans.length() + 1) ans += pos[0];
else if (res > ans.length() + 1) ans += pos[1];
else ans += pos[2];
}
if (n != 1) {
if (press(ans + pos[0]) == n) ans += pos[0];
else {
if (press(ans + pos[1]) == n) ans += pos[1];
else ans += pos[2];
}
}
return ans;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |