# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
164716 | IgorI | Combo (IOI18_combo) | C++17 | 47 ms | 588 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 <iostream>
#include <string>
using namespace std;
typedef long long ll;
string guess_sequence(int n)
{
string s;
int r = press("AB");
if (r)
{
int q = press("A");
if (q) s += "A";
else s += "B";
} else {
int q = press("X");
if (q) s += "X";
else s += "Y";
}
for (int i = 1; i < n; i++)
{
if (i + 1 == n)
{
string r;
int q;
if (s[0] == 'X' || s[0] == 'Y')
{
r = s + "A" + s + "B";
q = press(r) - i;
if (q == 0 && s[0] == 'X') return (s + "Y");
if (q == 0 && s[0] == 'Y') return (s + "X");
if (q == 1)
{
r = s + "A";
q = press(r) - i;
if (q == 0) return (s + "B");
if (q == 1) return (s + "A");
}
}
if (s[0] == 'A' || s[0] == 'B')
{
r = s + "X" + s + "Y";
q = press(r) - i;
if (q == 0 && s[0] == 'A') return (s + "B");
if (q == 0 && s[0] == 'B') return (s + "A");
if (q == 1)
{
r = s + "X";
q = press(r) - i;
if (q == 0) return (s + "Y");
if (q == 1) return (s + "X");
}
}
break;
}
string r;
int q;
if (s[0] == 'A') r = s + "BB" + s + "BX" + s + "BY" + s + "X";
if (s[0] == 'B') r = s + "AA" + s + "AX" + s + "AY" + s + "X";
if (s[0] == 'X') r = s + "AA" + s + "AB" + s + "AY" + s + "B";
if (s[0] == 'Y') r = s + "AA" + s + "AB" + s + "AX" + s + "B";
q = press(r) - i;
if (s[0] == 'A') if (q == 0) s += "Y"; else if (q == 1) s += "X"; else if (q == 2) s += "B";
if (s[0] != 'A')
{
if (q == 2) s += "A";
if (s[0] == 'B') if (q == 0) s += "Y"; else if (q == 1) s += "X";
if (s[0] != 'B')
{
if (q == 1) s += "B";
if (s[0] == 'X') if (q == 0) s += "Y";
if (s[0] != 'X')
{
if (q == 0) s += 'X';
}
}
}
}
return s;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |