# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
107246 | wonyoung | Combo (IOI18_combo) | C++14 | 117 ms | 712 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);
string guess_sequence(int N)
{
vector<char> buttons = { 'A', 'B', 'X', 'Y' };
string prefix;
char first_char;
int n;
n = press("AB");
if (n == 2)
{
prefix = "AB";
buttons.erase(buttons.begin());
}
else if (n == 1)
{
if (press("A") > 0)
{
prefix = "A";
buttons.erase(buttons.begin());
}
else
{
prefix = "B";
buttons.erase(buttons.begin()+1);
}
}
else
{
if (press("X") > 0)
{
prefix = "X";
buttons.erase(buttons.begin()+2);
}
else
{
prefix = "Y";
buttons.erase(buttons.begin()+3);
}
}
int i;
while (prefix.length() < N)
{
for (i=0; i< 2; i++)
{
string query_string = "";
string s = prefix;
s.push_back(buttons[i]);
query_string += s;
while (query_string.length() + s.length() + 1 < N * 4)
{
s.push_back(buttons[0]);
query_string += s;
}
n = press(query_string);
if (n > prefix.length())
{
break;
}
}
prefix.push_back(buttons[i]);
for (int i=prefix.length(); i<n; i++)
{
prefix.push_back(buttons[0]);
}
}
return prefix;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |