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 <vector>
#include<bits/stdc++.h>
using namespace std;
#include "messy.h"
#define all(a) (a).begin(), (a).end()
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
auto shuffle(vector<int>&a){
int n = a.size();
random_shuffle(all(a));
for(int i = 0; i < n; i ++){
int ii = rng() % n, jj = rng() % n;
while(ii == jj) jj = rng() % n;
swap(a[ii], a[jj]);
}
}
vector<int> restore_permutation(int n, int w, int r) {
for(int i = 0; i < n; i ++){
string s(n, '1');
for(int j = 0; j <= i; j ++) s[j] = '0';
add_element(s);
}
compile_set();
vector<int> p(n, -1);
for(int j = 0; j < n; j ++){
string s(n, '1');
vector<int> done(n);
for(int i = 0; i < n; i ++){
if(~p[i]) s[i] = '0', done[i] = 1;
}
vector<int> perm(n);
iota(all(perm), 0);
shuffle(perm);
for(int i : perm){
if(done[i]) continue;
s[i] = '0';
if(check_element(s)){
//cout << i << ' ' << j << endl;
p[i] = j;
break;
}
s[i] = '1';
}
}
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... |