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 <iostream>
#include <vector>
#include <array>
#include <string>
#include "combo.h"
#define endl '\n'
#define ll long long int
using namespace std;
constexpr array<char, 4> LETTERS { 'A', 'B', 'X', 'Y' };
string guess_sequence(int N)
{
string S = ".";
if(press("AB") > 0)
{
if(press("A") > 0)
S[0] = 'A';
else
S[0] = 'B';
}
else
{
if(press("X") > 0)
S[0] = 'X';
else
S[0] = 'Y';
}
if(N <= 1)
return S;
vector<string> l;
for(int i = 0 ; i < int(LETTERS.size()) ; ++i)
{
if(LETTERS[i] == S[0])
continue;
l.push_back(".");
l.back() = LETTERS[i];
}
for(int i = 1 ; i < N - 1 ; ++i)
{
string request =
S + l[0] + l[0]
+ S + l[0] + l[1]
+ S + l[0] + l[2]
+ S + l[1];
// cout << '(' << S << ')';
int p = press(request);
if(p == int(S.length()) + 0)
S += l[2];
if(p == int(S.length()) + 1)
S += l[1];
if(p == int(S.length()) + 2)
S += l[0];
// else
// press("error");
}
if(press(S + l[0]) > int(S.length()))
{
S += l[0];
}
else
{
if(press(S + l[1]) > int(S.length()))
S += l[1];
else
S += l[2];
}
return S;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |