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 <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define FOR(i, n) for (int i = 0; i < n; i++)
std::vector<int> restore_permutation(int n, int w, int r) {
int log = (int)(log2(n) + 0.5);
FOR(l, log){
string s(n, '0');
FOR(j, l) s[j] = '1';
FOR(i, n){
if(i & (1 << l)){
string t = s;
t[i] = '1';
add_element(t);
}
}
string t(n, '0');
FOR(j, n) if(s[j] == '0') t[j] = '1';
add_element(t);
}
compile_set();
vector<int> ids;
vector<int> p(n, 0);
FOR(l, log){
string s(n, '0');
for (int j : ids) s[j] = '1';
FOR(i, n){
if(s[i] == '1') continue;
string t = s;
t[i] = '1';
if(check_element(t)){
p[i] |= (1 << l);
}
}
s = string(n, '1');
for (int j : ids) s[j] = '0';
FOR(i, n){
if(s[i] == '0') continue;
string t = s;
t[i] = '0';
if(check_element(t)){
ids.push_back(i);
break;
}
}
}
return p;
}
# | 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... |