# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107281 | wonyoung | Combo (IOI18_combo) | C++14 | 1 ms | 232 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 <vector>
#include <string>
using namespace std;
int press(string p);
char binary_guess(string prefix)
{
int pn = prefix.length();
if (press(prefix + 'A' + prefix + 'B') > pn)
{
if (press(prefix + 'A') > pn)
return 'A';
return 'B';
}
if (press(prefix + 'X') > pn)
return 'X';
return 'Y';
}
string guess_sequence(int N)
{
vector<char> buttons = { 'A', 'B', 'X', 'Y' };
string prefix;
prefix += binary_guess("");
for (vector<char>::iterator it = buttons.begin(); it != buttons.end(); it++)
if (*it == prefix[0])
{
buttons.erase(it);
break;
}
int i;
bool skip = false;
int pn;
while ((pn = prefix.length()) < N - 1)
{
string query_string;
query_string += prefix + buttons[0];
for (int i=0; i<3; i++)
query_string += prefix + buttons[1] + buttons[i];
int n = press(query_string);
if (n == pn + 1)
prefix += buttons[0];
else if (n == pn + 2)
prefix += buttons[1];
else
prefix += buttons[2];
}
prefix += binary_guess(prefix);
return prefix;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |