# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
493164 | aSSSd | 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.
//#pragma GCC optimize("O2,unroll-loops")
//#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
#define forinc(x,a,b) for(int x=a;x<=b;x++)
string LET = "ABXY";
string guess_sequence(int n)
{
string ret = "";
if(press("AB"))
{
if(press("A")) ret += "A";
else ret += "B";
}
else
{
if(press("X")) ret += "X";
else ret += "Y";
}
if(n ==1 ) return ret;
string Char;
for(int i=0 ; i < 4 ; i++) if(LET[i] != ret[0]) Char.pb(LET[i]);
for(int i=1 ; i < n-1 ; i++)
{
string t = ret + Char[0] + ret + Char[1] + Char[0] + ret + Char[1] + Char[1] + ret +Char[1] + Char[2];
int val = press(t);
if(val == ret.size()) ret+=Char[2];
else if (val == ret.size() +1 ) ret+=Char[0];
else ret += Char[1];
}
if(ret.size()!= n)
{
int val =press(ret + Char[0]);
if(val == n) ret += Char[0];
else
{
val = press(ret + Char[1]);
if(val == n) ret+=Char[1];
else ret+=Char[2];
}
}
return ret;
}