# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
587820 | IvanJ | 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>
#define all(a) (a).begin(), (a).end()
using namespace std;
string guess_sequence(int n) {
string p = "", s = "";
if(press("A")) s = "A";
else if(press("B")) s = "B";
else if(press("X")) s = "X";
else s = "Y";
set<string> S;
S.insert("A"), S.insert("B"), S.insert("X"), S.insert("Y");
S.erase(s);
vector<string> v(all(S));
for(int i = 1;i < n - 1;i++) {
p = s + v[0];
for(int j = 0;j < 3;j++)
p += s + v[1] + v[j];
int x = press(p);
if(x == (int)s.size() + 1) s += v[0];
else if(x == (int)s.size() + 2) s += v[1];
else s += v[2];
}
assert(int)s.size() == (n - 1));
if(press(s + v[0]) == n) s += v[0];
else if(press(s + v[1]) == n) s += v[1];
else s += v[2];
return s;
}