# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1006712 | devariaota | Combo (IOI18_combo) | C++17 | 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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
string guess_sequence(int N) {
int n = N;
string now = "", S;
char ch[4] = {'A', 'B', 'X', 'Y'};
int k = press("AB");
if(k >= 1) {
k = press("A");
if(k == 1) now = "A";
else now = "B";
}
else {
k = press("X");
if(k >= 1) now = "X";
else now = "Y";
}
if(n == 1) return now;
for(int i = 1; i + 1 < n; i++) {
vector<char> p;
for(auto j : ch) {
if(now[0] == j) continue;
p.pb(j);
}
string hai = now + p[0] + now + p[1] + p[0] + now + p[1] + p[1] + now + p[1] + p[2];
k = press(hai);
if(k == i - 1) now = now + p[2];
else if(k == i) now = now + p[0];
else now = now + p[1];
}
int k = press(now + 'A' + now + 'B');
if(k == n) {
k = press(now + 'A');
if(k == n) S = now + 'A';
else S = now + 'B';
} else {
k = press(now + 'X');
if(k == n) S = now + 'X';
else S = now + 'Y';
}
return S;
}