# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
785905 | Boas | Combo (IOI18_combo) | C++17 | 87 ms | 924 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>
#define ALL(x) x.begin(), x.end()
using namespace std;
string guess_sequence(int N)
{
vector<char> buttons = {'A', 'B', 'X', 'Y'};
string S;
for (int i = 0; i < 3; i++)
{
string p = S + buttons[i];
if (press(p) == 1)
{
S = p;
buttons.erase(find(ALL(buttons), buttons[i]));
break;
}
}
if (S.size() == 0)
S += 'Y';
while (S.size() < N)
{
vector<string> all = {S};
while (((all.size() * 3 + 1) / 2) * (all[0].size() + 1) + 1 <= 4 * N)
{
cerr << ((all.size() * 3) * (all[0].size() + 1) + 1) / 2 << "<=" << 4 * N << endl;
int s = all.size();
for (int i = 0; i < s; i++)
{
all.push_back(all[i] + buttons[1]);
all.push_back(all[i] + buttons[2]);
all[i] += buttons[0];
}
if (all[0].size() == N)
break;
}
int min = 0;
int max = all.size() - 1;
while (max != min)
{
int k = (max + min) / 2;
string p;
for (int i = min; i <= k; i++)
{
p += all[i];
}
cerr << "p.size() = " << p.size() << " en 4N = " << 4 * N << endl;
// resterende ruimte opvullen met random junk
int res = press(p);
// if( S.size() < res < all[0].size()) { filter all op mogelijkheden!;}
if (res == all[0].size())
{
max = k;
}
else
{
min = k + 1;
}
}
S = all[min];
// cerr << "Done?!" << endl;
}
return S;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |