제출 #369857

#제출 시각아이디문제언어결과실행 시간메모리
369857JasiekstrzUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms492 KiB
#include<bits/stdc++.h> #include "messy.h" #define fi first #define se second using namespace std; string s; vector<int> ans; inline void swp(int x) { s[x]=(s[x]=='0' ? '1':'0'); return; } void add(int r,int m,int n) { if(m==n) return; int i; for(i=r+m;i<n;i+=2*m) { swp(i); add_element(s); swp(i); } for(i=r+m;i<n;i+=2*m) swp(i); add(r,2*m,n); for(i=r;i<n;i+=m) swp(i); add(r+m,2*m,n); for(i=r;i<n;i+=2*m) swp(i); return; } void check(vector<int> av,int w,int p) { if(av.size()==1) { ans[av[0]]=w; return; } vector<int> tmp[2]; for(auto v:av) { swp(v); tmp[check_element(s)].push_back(v); swp(v); } for(auto v:tmp[1]) swp(v); check(tmp[0],w,2*p); for(auto v:av) swp(v); check(tmp[1],w+p,2*p); for(auto v:tmp[0]) swp(v); return; } vector<int> restore_permutation(int n,int w,int r) { s=string(n,'0'); ans.resize(n); add(0,1,n); compile_set(); vector<int> tmp(n); for(int i=0;i<n;i++) tmp[i]=i; check(tmp,0,1); return ans; }
#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...