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>
using namespace std;
typedef int64_t llo;
#define mp make_pair
#define pb push_back
#define a first
#define b second
//#define endl '\n'
mt19937 rng;
void add_element(string x);
bool check_element(string x);
void compile_set();
//#include "messy.h"
std::vector<int> restore_permutation(int n, int w, int r) {
rng=mt19937(chrono::steady_clock::now().time_since_epoch().count());
for(int i=0;i<n;i++){
string s="";
for(int j=0;j<i+1;j++){
s+="1";
}
for(int j=i+1;j<n;j++){
s+="0";
}
// cout<<s<<endl;
add_element(s);
}
compile_set();
set<int> cur;
for(int j=0;j<n;j++){
cur.insert(j);
}
set<int> cur2;
vector<int> ans;
for(int i=0;i<n;i++){
ans.pb(0);
}
for(int ii=0;ii<n;ii++){
vector<int> kk;
for(auto j:cur){
kk.pb(j);
}
shuffle(kk.begin(),kk.end(),rng);
for(auto j:kk){
string s="";
for(int i=0;i<n;i++){
if(i==j or cur2.find(i)!=cur2.end()){
s+="1";
}
else{
s+="0";
}
}
// cout<<s<<endl;
if(check_element(s)){
ans[j]=ii;
// ans.pb(j);
cur.erase(j);
cur2.insert(j);
break;
}
}
}
// check_element("0");
return ans;
}
/*int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
return 0;
}
*/
/*
g++ -o aa -O2 messy.cpp grader.cpp -std=c++14
*/
# | 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... |