# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
784068 | zsombor | 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 <iostream>
#include <vector>
#include "messy.h"
using namespace std;
string s = "";
char opp(int i) {
return (s[i] == '0' ? '1' : '0');
}
vector <int> restore_permutation(int n, int w, int r) {
int l; for (int j = 0; j <= 7; j++) if (n & (1 << j)) l = j;
for (int i = 0; i < n; i++) s.push_back('0');
for (int i = 1; i < n; i += 2) { s[i] = '1'; add_element(s); s[i] = '0'; }
for (int j = 1; j < l; j++) {
for (int i = 0; i < n; i++) s[i] = (i & (1 << (j - 1))) ? '1' : '0';
for (int i = 0; i < n; i++) {
if ((i & (1 << j)) == 0) continue;
s[i] = opp(i);
add_element(s);
s[i] = opp(i);
}
}
compile_set();
fill(s.begin(), s.end(), '0');
vector <vector <bool>> b(n, vector <bool>(l, false));
for (int i = 0; i < n; i++) { s[i] = '1'; b[i][0] = check_element(s); s[i] = '0'; }
for (int j = 1; j < l; j++) {
for (int i = 0; i < n; i++) s[i] = b[i][j - 1] ? '1' : '0';
for (int i = 0; i < n; i++) {
s[i] = opp(i);
b[i][j] = check_element(s);
s[i] = opp(i);
}
}
vector <int> ans(n, 0);
for (int i = 0; i < n; i++) {
for (int j = 0; j < l; j++) {
if (b[i][j]) ans[i] += (1 << j);
}
}
return ans;
}
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... |