# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
754128 | kirakaminski968 | 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 <bits/stdc++.h>
using namespace std;
string guess_sequence(int N){
string ask = "AB"; string now = "";
char arr[4] = {'A','B','X','Y'};
int ok = press(ask), used;
if(ok == 2){
now += 'A';
used = 0;
}
else if(ok == 1){
ask = "A";
ok = press(ask);
if(ok == 1) {now += 'A'; used = 0;}
else {now += 'B'; used = 1;}
}
else{
ask = "X";
ok = press(ask);
if(ok == 1) {now += 'X'; used = 2;}
else {now += 'Y'; used = 3;}
}
int add;
if(used == 0) add = 1;
else add = 0;
//cout << used << " " << add << "\n";
for(int i = 1;i<=N-2;++i){
string ask;
string cur = now + arr[add];
int newc = -1, newc2 = -1;
for(int j = 0;j<4;++j){
if(j != used){
ask += cur+arr[j];
if(newc == -1 && j != add) newc = j;
else if(j != add) newc2 = j;
}
}
ask += now+arr[newc];
ok = press(ask);
if(ok == i+2){
now += arr[add];
}
else if(ok == i+1){
now += arr[newc];
}
else{
now += arr[newc2];
}
}
for(int i = 0;i<4;++i){
if(i != used){
ok = press(now+arr[i]);
if(ok == N){
return now+arr[i];
}
}
}
}