# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77351 | Just_Solve_The_Problem | 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>
#include "grader.cpp"
#include "combo.h"
#define pb push_back
#define sz(s) (int)s.size()
using namespace std;
char c[] = {'A', 'B', 'X', 'Y'};
int ask(string s) {
return press(s);
}
string guess_sequence(int N) {
string ans;
if (ask("AB"))
if (ask("A"))
ans.pb('A');
else
ans.pb('B');
else
if (ask("X"))
ans.pb('X');
else
ans.pb('Y');
vector < char > vec;
for (int i = 0; i < 4; i++) {
if (c[i] == ans[0])
continue;
vec.pb(c[i]);
}
for (int i = 1; i < N - 1; i++) {
int temp = ask(ans + vec[0] + vec[0] + ans + vec[0] + vec[1] + ans + vec[0] + vec[2] + ans + vec[1]);
if (temp == sz(ans)) {
ans.pb(vec[2]);
} else if (temp == sz(ans) + 1) {
ans.pb(vec[1]);
} else {
ans.pb(vec[0]);
}
}
if (N == 1) return ans;
if (ask(ans + vec[0]) == N)
ans.pb(vec[0]);
else if (ask(ans + vec[1]) == N)
ans.pb(vec[1]);
else
ans.pb(vec[2]);
return ans;
}