이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <vector>
#include <bits/stdc++.h>
#include "messy.h"
using namespace std;
void dfs1(int l,int r,int n){
if (l==r) return;
int mid=(l+r)/2;
for (int i=l; i<=mid; i++){
string s="";
for (int j=0; j<n; j++){
if (j<l||j>r||j==i) s+='1';
else s+='0';
}
add_element(s);
}
dfs1(l,mid,n);
dfs1(mid+1,r,n);
}
vector <int> ans;
void dfs2(int l,int r,vector <int> can,int n){
if (can.size()==1){
ans[can[0]]=l;
return;
}
vector <int> lef,rig;
for (int i:can){
string s="";
for (int j=0; j<n; j++) s+='1';
for (int j:can) s[j]='0';
s[i]='1';
if (check_element(s)) lef.push_back(i);
else rig.push_back(i);
}
int mid=(l+r)/2;
dfs2(l,mid,lef,n);
dfs2(mid+1,r,rig,n);
}
vector <int> restore_permutation(int n,int w,int r){
dfs1(0,n-1,n);
compile_set();
vector <int> v;
for (int i=0; i<n; i++) v.push_back(i);
ans.resize(n);
dfs2(0,n-1,v,n);
return ans;
}
# | 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... |