# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1071454 | mc061 | Unscrambling a Messy Bug (IOI16_messy) | C++14 | 1 ms | 356 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.
#pragma once
#include <bits/stdc++.h>
using namespace std;
void add_element(std::string x);
bool check_element(std::string x);
void compile_set();
std::vector<int> restore_permutation(int n, int w, int r) {
srand(123123);
string s(n, '0');
for (int i = 0; i < n-1; ++i) {
s[i] = '1';
add_element(s);
}
compile_set();
vector<pair<int, int>> know;
vector<bool> busy(n, false);
int c = 0;
for (int bits = 1; bits < n; ++bits) {
string cur(n, '0');
for (auto [was, now] : know) {
cur[now] = '1';
}
vector<string> pot;
for (int i = 0; i < n; ++i) {
if (cur[i] == '1') continue;
cur[i] = '1';
pot.push_back(cur);
cur[i] = '0';
}
random_shuffle(pot.begin(), pot.end());
for (int i = 0; i < pot.size(); ++i) {
// cerr << "ck ";
// for (char c : pot[i]) cerr << c;
// cerr << " : ";
bool x;
if (i == pot.size() - 1)
x = true;
else
x = check_element(pot[i]);
++c;
// cerr << x << endl;
if (!x) continue;
for (int j = 0; j < n; ++j) {
if (pot[i][j] != '1' || busy[j]) continue;
busy[j] = true;
know.push_back({bits-1, j});
}
break;
}
}
vector<int> perm(n, -1);
for (auto [was, now] : know) {
perm[now] = was;
}
for (int i = 0; i < n; ++i) {
if (perm[i] == -1) perm[i] = n-1;
}
// cerr << c << endl;
// cerr << endl;
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... |