Submission #593158

#TimeUsernameProblemLanguageResultExecution timeMemory
593158Koosha_mvUnscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
2 ms468 KiB
#include "messy.h" #include <bits/stdc++.h> using namespace std; #define dbgv(v) cout<<#v<<" = "; f(i,0,v.size()) cout<<v[i]<<" "; cout<<endl #define dbga(a,x,y) cout<<#a<<" = "; f(i,x,y) cout<<a[i]<<" "; cout<<endl #define erorp(x) cout<<#x<<"={"<<x.F<<" , "<<x.S<<"}"<<endl #define eror(x) cout<<#x<<'='<<(x)<<endl #define f_(i,a,b) for(int i=a;i>=b;i--) #define f(i,a,b) for(int i=a;i<b;i++) #define nb(x) __builtin_popcount(x) #define all(v) v.begin(),v.end() #define bit(n,k) (((n)>>(k))&1) #define Add(x,y) x=(x+y)%mod #define maxm(a,b) a=max(a,b) #define minm(a,b) a=min(a,b) #define lst(x) x[x.size()-1] #define sz(x) int(x.size()) #define mp make_pair #define ll long long #define pb push_back #define S second #define F first const int N=200; int n,lg; vector<int> ans; void solve(vector<int> vec,int l,string now){ if(vec.size()==1) return ; vector<int> lc,rc; string L=now,R=now; for(auto x : vec){ now[x]='1'; if(check_element(now)==0){ lc.pb(x); R[x]='1'; } else{ rc.pb(x); L[x]='1'; ans[x]^=(1<<l); } now[x]='0'; } //dbgv(lc); //dbgv(rc); solve(lc,l-1,L); solve(rc,l-1,R); } vector<int> restore_permutation(int _n, int w, int r) { n=_n; ans.resize(n); while((1<<lg)<n) lg++; f(l,0,lg){ f(i,0,n){ if(bit(i,l)==0) continue ; string s(n,'0'); f(j,0,n){ if(j==i || (j>>(l+1))!=(i>>(l+1))){ s[j]='1'; } } //eror(s); add_element(s); } } compile_set(); vector<int> vec(n); iota(all(vec),0); string s(n,'0'); solve(vec,lg-1,s); return ans; } /* add_element("0"); compile_set(); check_element("0"); */
#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...