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 "messy.h"
#define fr first
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define sc second
#define all(s) s.begin(), s.end()
#define rc(s) return cout << s, 0
using namespace std;
int N, mp[200];
void recursiv(int l, int r){
if(l == r) return;
string s = "";
for(int i=1;i<=N;i++) s += '0';
for(int i=0;i<l;i++) s[i] = '1';
for(int i=r+1;i<N;i++) s[i] = '1';
int mid = l + (r - l) / 2;
for(int i=l;i<=mid;i++){
s[i] = '1';
add_element(s);
s[i] = '0';
}
recursiv(l, mid);
recursiv(mid + 1, r);
}
void davai(int l, int r, vector<int>tz){
if(l == r){
mp[l] = tz[0];
return;
}
else{
int mid = l + (r - l) / 2;
string s;
for(int i=0;i<N;i++) s += '1';
for(auto it : tz) s[it] = '0';
vector<int>le, ri;
for(auto it : tz){
s[it] = '1';
if(check_element(s)){
le.push_back(it);
}
else{
ri.push_back(it);
}
s[it] = '0';
}
davai(l, mid, le);
davai(mid + 1, r, ri);
}
}
vector<int> restore_permutation(int n, int w, int r) {
N = n;
recursiv(0, n - 1);
compile_set();
vector<int>tz;
for(int i=0;i<N;i++) tz.push_back(i);
davai(0, n - 1, tz);
vector<int>ans;
for(int i=0;i<N;i++){
ans.push_back(mp[i]);
}
vector<int>lmao(N, 0);
for(int i=0;i<(int)ans.size();i++){
lmao[ans[i]] = i;
}
return lmao;
}
# | 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... |