# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
743489 | boris_mihov | Unscrambling a Messy Bug (IOI16_messy) | C++17 | 2 ms | 468 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 "messy.h"
#include <algorithm>
#include <iostream>
#include <numeric>
#include <cassert>
#include <vector>
#include <bitset>
#include <random>
typedef long long llong;
const int MAXN = 256;
const int MAXLOG = 8;
const int INF = 1e9;
std::vector <int> perm;
std::vector <int> restore_permutation(int n, int w, int r)
{
perm.resize(n, 0);
std::string element(n, '0');
for (int bit = 0 ; (1 << bit) < n ; ++bit)
{
for (int i = 0 ; i < n ; ++i)
{
if (i & (1 << bit))
{
if (element[i] == '0') element[i] = '1';
else element[i] = '0';
add_element(element);
if (element[i] == '0') element[i] = '1';
else element[i] = '0';
}
}
for (int i = 0 ; i < n && bit > 0 ; ++i)
{
if (i & (1 << bit - 1))
{
element[i] = '0';
}
}
for (int i = 0 ; i < n ; ++i)
{
if (i & (1 << bit))
{
element[i] = '1';
}
}
}
compile_set();
std::vector <int> last;
std::fill(element.begin(), element.end(), '0');
for (int bit = 0 ; (1 << bit) < n ; ++bit)
{
std::vector <int> curr;
for (int i = 0 ; i < n ; ++i)
{
if (element[i] == '0') element[i] = '1';
else element[i] = '0';
if (check_element(element))
{
perm[i] |= (1 << bit);
curr.push_back(i);
}
if (element[i] == '0') element[i] = '1';
else element[i] = '0';
}
for (const int &i : last)
{
element[i] = '0';
}
for (const int &i : curr)
{
element[i] = '1';
}
last = curr;
}
return perm;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |