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>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define endl '\n'
#define INF 1e9+7
#define all(x) x.begin(),x.end()
using namespace std;
using namespace __gnu_pbds;
using ll=long long;
using pii=pair<int,int>;
using ppi=pair<int,pii>;
using oset=tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>;
template<typename T>
void _print(vector<T> x) {cerr<<"{"; for(auto e:x) cerr<<e<<","; cerr<<"}";}
void _print(pii x) {cerr<<"{"<<x.first<<","<<x.second<<"}";}
template<typename T>
void _print(T x) {cerr<<x;}
void dbg() {cerr<<endl;}
template<typename Head,typename... Tail>
void dbg(Head H,Tail... T) {
_print(H);
if(sizeof...(T)) cerr<<",";
else cerr<<"\"]";
dbg(T...);
}
#define debug(...) cerr<<"["<<#__VA_ARGS__<<"]:[\"",dbg(__VA_ARGS__)
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
std::vector<int> restore_permutation(int n, int w, int r) {
vector<int> ans(n,-1);
string zero(n,'0');
string one="";
for(int i=0;i<n;i++) {
one.push_back('1');
zero.pop_back();
// debug(one+zero);
add_element(one+zero);
}
compile_set();
for(int i=0;i<n;i++) {
string temp(n,'0');
for(int j=0;j<i;j++) {
temp[ans[j]]='1';
}
// debug(i,temp);
for(int j=0;j<n;j++) {
if(temp[j]=='0') {
temp[j]='1';
bool res=check_element(temp);
if(res) {
// debug(temp);
ans[i]=j; break;
}
temp[j]='0';
}
}
}
vector<int> ans_real(n);
for(int i=0;i<n;i++) {
ans_real[ans[i]]=i;
}
return ans_real;
}
# | 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... |