# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
647637 | Truitadepatates | Combo (IOI18_combo) | C++14 | 43 ms | 596 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;
const int M = 4;
const char A[] = "ABXY";
int guess_one(const string& s) {
int len = press(s + A[0] + s + A[1]);
int idx = 2*(len < s.length()+1);
len = press(s + A[idx]);
idx += (len < s.length()+1);
return idx;
}
string guess_sequence(int N) {
int idx[M];
for (int i = 0; i < M; i++) {
idx[i] = i;
}
string s;
int id = guess_one(s);
s += A[id];
swap(idx[id], idx[M-1]);
for (int i = 0; i < N-2; i++) {
string z;
for (int j = 0; j < M-1; j++) {
z += s + A[idx[0]] + A[idx[j]];
}
z += s + A[idx[1]];
int len = press(z);
if (len == i+3) {
s += A[idx[0]];
} else if (len == i+2) {
s += A[idx[1]];
} else {
s += A[idx[2]];
}
}
if (N > 1) {
int id = guess_one(s);
s += A[id];
}
return s;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |