제출 #618150

#제출 시각아이디문제언어결과실행 시간메모리
618150rrrr10000Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...