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;
int n;
char get_first_letter()
{
string s = "AB", t = "XY";
int len = press(s);
if (len != 0)
{
s = "A";
len = press(s);
if (len != 0)
return 'A';
else
return 'B';
}
else
{
t = "X";
len = press(t);
if (len != 0)
return 'X';
else
return 'Y';
}
}
string guess_sequence(int N)
{
n = N;
char fl = get_first_letter();
string res = "";
res = res + fl;
vector < char > let;
if (fl != 'A')
let.push_back('A');
if (fl != 'B')
let.push_back('B');
if (fl != 'X')
let.push_back('X');
if (fl != 'Y')
let.push_back('Y');
for (int step = 2; step < N; step ++)
{
string f1 = res + let[0] + let[0];
string f2 = res + let[0] + let[1];
string f3 = res + let[0] + let[2];
string f4 = res + let[1];
string comb = f1 + f2 + f3 + f4;
int len = press(comb);
if (len == step + 1)
{
res = res + let[0];
}
else if (len == step)
{
res = res + let[1];
}
else
{
res = res + let[2];
}
}
if (N > 1)
{
string f1 = res + let[0];
string f2 = res + let[1];
string comb = f1 + f2;
if (press(comb) == N)
{
if (press(f1) == N)
res = f1;
else
res = f2;
}
else
{
res = res + let[2];
}
}
///cout << res << endl;
return res;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |