# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
434089 | Tiago_Marques | Combo (IOI18_combo) | C++17 | 1 ms | 260 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 "combo.h"
#include <bits/stdc++.h>
using namespace std;
std::string guess_sequence(int N)
{
string s, p;
char option[4] = {'A', 'B', 'X', 'Y'};
int x;
p = "AB";
x = press(p);
if (x)
{
p = "A";
x = press(p);
if (x)
{
s = "A";
}
else
{
s = "B";
swap (option[0], option[1]);
}
}
else
{
p = "X";
x = press(p);
if (x)
{
s = "X";
swap (option[0], option[2]);
}
else
{
s = "Y";
swap (option[0], option[3]);
}
}
while (s.size() < N - 1)
{
p.clear();
p += s;
p += option[1];
p += option[1];
p += s;
p += option[1];
p += option[2];
p += s;
p += option[1];
p += option[3];
p += s;
p += option[2];
p += option[0];
x = press (p);
if (x == s.size())
{
s += option[3];
}
if (x == s.size() + 1)
{
s += option[2];
}
if (x == s.size() + 2)
{
s += option[1];
}
}
s += option[1];
if (press (s) == N)
return s;
s .pop_back();
s += option[2];
if (press(s) == N)
return s;
s.pop_back();
s += option[3];
return s;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |