# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
240544 | dannber_BR | 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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
string Btns[] = {"A","B","X","Y"};
string guess_sequence(int N) {
string s = "";
string p = "";
int p = 0;
int long_gues = 0;
if(press(Btns[0]+Btns[1]))
{
if(press(Btns[0]))
{
s += Btns[0];p = Btns[1]; long_gues++;
}
else
{
s += Btns[1];p = Btns[0]; long_gues++;
}
}
else
{
if(press(Btns[2]))
{
s += Btns[2];p = Btns[3]; long_gues++;
}
else
{
s += Btns[3];p = Btns[2]; long_gues++;
}
}
if (N == 1)
{
return s;
}
for(int i = long_gues + 1;i <= N;)
{
bool fact = false;
if (press(s + p) == i)
{
s += p;
fact = true;
long_gues++;
i++;
}
else if (fact == false)
{
for(int j = 0;j <= 3;j++)
{
if(Btns[j] != p && !fact)
{
if (press(s + Btns[j]) == i)
{
s += Btns[j];
fact = true;
p = Btns[j];
long_gues++;
i++;
}
}
}
}
}
return s;
}