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;
char c[4];
string res;
void Add()
{
string s = "";
for(int i = 0 ; i < 3 ; i++)
{
s += res;
s.push_back(c[0]);
s.push_back(c[i]);
}
s += res;
s.push_back(c[1]);
s.push_back(res[0]);
int tmp = press(s);
int sz = res.size();
if(tmp == sz + 2)
res.push_back(c[0]);
else if(tmp == sz + 1)
res.push_back(c[1]);
else
res.push_back(c[2]);
}
string guess_sequence(int n)
{
int a1 = press("AB") , a2 = press("AX");
if(a1 > 0 && a2 > 0)
{
c[0] = 'B';
c[1] = 'X';
c[2] = 'Y';
res.push_back('A');
}
else if(a1 > 0)
{
c[0] = 'A';
c[1] = 'X';
c[2] = 'Y';
res.push_back('B');
}
else if(a2 > 0)
{
c[0] = 'A';
c[1] = 'B';
c[2] = 'Y';
res.push_back('X');
}
else
{
c[0] = 'A';
c[1] = 'B';
c[2] = 'X';
res.push_back('Y');
}
if(n == 1)
return res;
for(int i = 1 ; i + 2 <= n ; i++)
Add();
string s1 = res + c[0] , s2 = res + c[1];
a1 = press(s1); a2 = press(s2);
if(a1 == n)
return s1;
else if(a2 == n)
return s2;
res.push_back(c[2]);
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |