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<bits/stdc++.h>
#include <vector>
using namespace std;
#include "messy.h"
std::vector<int> restore_permutation(int N, int w, int r) {
for(int i = 1; i <= N; i++){
string t = string(i,'0')+string(N-i,'1');
add_element(t);
}
compile_set();
vector<int> res (N);
vector<bool> taken (N);
for(int i = 1; i <= N; i++){
string s (N, '1');
for(int j = 0; j < N; j++){
if(taken[j]) s[j] = '0';
}
vector<int> indices;
for(int j = 0; j < N; j++) if(!taken[j]) indices.push_back(j);
random_shuffle(indices.begin(), indices.end());
for(auto j : indices){
if(!taken[j]){
s[j] = '0';
if(check_element(s)){
res[j] = i-1;
taken[j] = 1;
break;
}
s[j] = '1';
}
}
}
return res;
}
# | 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... |