# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
419248 | peuch | 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) {
string ord[4] = {"A", "B", "X", "Y"};
if(press("AB")){
if(press("A")) swap(ord[0], ord[0]);
else swap(ord[0], ord[1]);
}
else{
if(press("X")) swap(ord[0], ord[2]);
else swap(ord[0], ord[3]);
}
ans = ord[0];
if(N == 1) return ans;
for(int i = 2; i < N; i++){
string guess = ans + ord[1];
guess = guess + ans + ord[2] + ord[1];
guess = guess + ans + ord[2] + ord[2];
guess = guess + ans + ord[2] + ord[3];
int cnt = press(guess);
if(cnt == i) ans = ans + ord[1];
else if(cnt == i + 1) ans = ans + ord[2];
else ans = ans + ord[3];
}
if(press(ans + ord[1]) == N) return ans + ord[1];
if(press(ans + ord[2]) == N) return ans + ord[2];
return ans + ord[3];
}