# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
417478 | LouayFarah | 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;
#define pb push_back
int press(string p)
string guess_sequence(int n)
{
string first = "A";
if(press("A")==1)
first = "A";
if(press("B")==1)
first = "B";
if(press("X")==1)
first = "X";
if(press("Y")==1)
first = "Y";
string res = first;
int curr = 1;
vector<string> used;
if(first!="A")
used.pb("A");
if(first!="B")
used.pb("B");
if(first!="X")
used.pb("X");
if(first!="Y")
used.pb("Y");
string processed = first;
while(curr<n)
{
for(int i = 0; i<3; i++)
{
if(used[i]==processed)
continue;
string temp = "";
for(int j = 0; j<n-curr; j++)
{
temp+=used[i];
}
string s = res + temp;
int nb = press(s);
if(nb>curr)
{
for(int j = curr; j<nb; j++)
{
res.pb(s[j]);
}
curr = nb;
processed = used[i];
break;
}
}
}
return res;
}