| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1297417 | alexiah | Combo (IOI18_combo) | C++20 | 0 ms | 0 KiB |
#include "combo.h"
using namespace std;
string guess_sequence(int n) {
string ans, opc;
opc.push_back('A'); opc.push_back('B'); opc.push_back('X'); opc.push_back('Y');
int f1 , f2;
f1 = press("AB"); f2 = press("AX");
if(f1 >= 1 && f2 >= 1){
ans.push_back('A');
swap(opc[0] , opc[3]); opc.pop_back();
swap(opc[0] , opc[1]); swap(opc[1] , opc[2]);
}
else if(f1 == 1 && f2 == 0){
ans.push_back('B');
swap(opc[1] , opc[3]); opc.pop_back();
swap(opc[1] , opc[2]);
}
else if(f1 == 0 && f2 == 1){
ans.push_back('X');
swap(opc[2] , opc[3]); opc.pop_back();
}
else{
ans.push_back('Y'); opc.pop_back();
}
for(int i = 1; i < n; i++){
string aux;
aux += (ans + opc[0] + opc[0]);
aux += (ans + opc[0] + opc[1]);
aux += (ans + opc[0] + opc[2]);
aux += (ans + opc[1]);
int act = press(aux);
if(act == i + 2) ans += opc[0];
else if(act == i + 1) ans += opc[1];
else ans += opc[2];
}
int l1 , l2;
l1 = press(opc[0] + opc[1]) , l2 = press(opc[0] + opc[2]);
if(l1 >= 1 && l2 >= 1) ans += opc[0];
else if(l1 >= 1 && l2 == 0) ans += opc[1];
else ans += opc[2];
return ans;
}
