# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
529494 | sunnat | Combo (IOI18_combo) | C++14 | 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){
srand(time(0));
string s;
if(press("AB")){
if(press("A")) s = "A";
else s = "B";
}
else{
if(press("X")) s = "X";
else s = "Y";
}
string t;
for(int i = 0; i < 4; i ++)
if("ABXY"[i] != s[0]) t.push_back("ABXY"[i]);
int l = 1;
for(int i = 1; i < n; i ++)
s.push_back(t[rand() % 3]);
int L;
string nt;
while(l != n){
L = press(s);
if(L == n) break;
if(L == l) nt.push_back(s[l]);
else{
nt = "";
l = L;
}
int x = rand() % (3 - nt.size());
int y = -1;
while(x >= 0){
y ++;
if(nt.find(t[y]) == string::npos)
x --;
}
s[l] = t[y];
for(int i = l + 1; i < n; i ++)
s[i] = t[rand()%3];
}
return s;
}