# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77563 | scanhex | Combo (IOI18_combo) | C++17 | 74 ms | 624 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 <bits/stdc++.h>
using namespace std;
#include "combo.h"
using arr = array<bool, 4>;
std::string guess_sequence(int N) {
string ss = "XYAB";
int L = 0, R = 4;
while (R - L > 1)
{
int M = (L + R) / 2;
string s;
for (int i = L; i < M; ++i)
s.push_back(ss[i]);
if (press(s) >= 1)
R = M;
else
L = M;
}
string cur;
cur.push_back(ss[L]);
if (N == 1)
return cur;
string s = "XYAB";
s.erase(find(s.begin(), s.end(), cur[0]));
for (int i = 1; i < N - 1; ++i)
{
string que = cur;
que.push_back(s[0]);
for (int j = 0; j < 3; ++j)
{
que += cur;
que.push_back(s[1]);
que.push_back(s[j]);
}
int mem = press(que);
if (mem == i)
cur.push_back(s[2]);
else if (mem == i + 1)
cur.push_back(s[0]);
else
cur.push_back(s[1]);
}
for (int i = 0; i < 2; ++i)
{
string que = cur;
que.push_back(s[i]);
if (press(que) == N)
{
cur = que;
break;
}
}
if (cur.size() < N)
cur.push_back(s.back());
return cur;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |