# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
318407 | soroush | 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>
#include "combo.h"
using namespace std;
string guess_sequence(int n){
string ans = "";
vector < string > vec = {"A" , "B" , "X" , "Y"};
auto rng = std::default_random_engine {};
random_shuffle(vec.begin() , vec.end() , rng);
string f = vec[0];
if(press(ans + vec[1]) == 1)
f = vec[1];
else if(press(ans + vec[2]) == 1)
f = vec[2];
else if(press(ans + vec[3]) == 1)
f = vec[3];
ans += f;
vector < string > v;
for(int i = 0 ; i < 4 ; i ++){
auto s = vec.back();
vec.pop_back();
if(s!=f)
v.push_back(s);
}
for(int i = 1 ; i < n-1 ; i ++){
int res = press(ans + v[0] + ans + v[1] + v[0] + ans + v[1] + v[1] + ans + v[1] + v[2]);
if(res == i)
ans += v[2];
if(res == i + 1)
ans += v[0];
if(res == i + 2)
ans += v[1];
}
if(n == 1)return(ans);
f = v[0];
if(press(ans + v[1]) == n)
f = v[1];
else if(press(ans + v[2]) == n)
f = v[2];
ans += f;
return(ans);
}