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;
std::string guess_sequence(int n)
{
vector<string> cont;
string seq;
int cc = press("AB");
if(cc)
{
if(press("A"))
seq = "A";
else
seq = "B";
}
else
{
if(press("X"))
seq = "X";
else
seq = "Y";
}
for (auto c : {"A", "B", "X", "Y"})
if (c != seq)
cont.push_back(c);
if(n == 1)
return seq;
for (int i = 1; i < n - 1; i++)
{
string cpress = seq + cont[0] + seq + cont[1] + cont[0] + seq + cont[1] + cont[1] + seq + cont[1] + cont[2];
int cur = press(cpress) - i;
if(cur == 1)
seq += cont[0];
else if(cur == 2)
seq += cont[1];
else
seq += cont[2];
}
for(auto c:cont)
{
if(c == cont[2])
{
seq += c;
break;
}
if(press(seq + c) == n)
{
seq += c;
break;
}
}
return seq;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |