이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "messy.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(a) a.begin(),a.end()
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pb emplace_back
template<class T> void out(T a){cout<<a<<endl;}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<endl;}
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
const ll inf=1001001001001001001;
std::vector<int> restore_permutation(int n, int w, int r) {
function<void(vi)> add=[&](vi v){
if(v.size()==1)return;
vi a,b;
rep(i,v.size()/2)a.pb(v[i]);
REP(i,v.size()/2,v.size())b.pb(v[i]);
string tmp(n,'1');
for(ll x:v)tmp[x]='0';
for(ll x:a){
tmp[x]='1';
add_element(tmp);
tmp[x]='0';
}
add(a);add(b);
};
vector<int> res(n);
function<void(vi,vi)> sol=[&](vi v,vi u){
if(v.size()==1){
res[u[0]]=v[0];
return;
}
vi av,bv,au,bu;
rep(i,v.size()/2)av.pb(v[i]);
REP(i,v.size()/2,v.size())bv.pb(v[i]);
string tmp(n,'1');
for(ll x:u)tmp[x]='0';
for(ll x:u){
tmp[x]='1';
if(check_element(tmp))au.pb(x);
else bu.pb(x);
tmp[x]='0';
}
sol(av,au);sol(bv,bu);
};
vi al(n);rep(i,n)al[i]=i;
add(al);
compile_set();
sol(al,al);
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... |