제출 #535441

#제출 시각아이디문제언어결과실행 시간메모리
535441mario05092929Unscrambling a Messy Bug (IOI16_messy)C++14
100 / 100
20 ms468 KiB
#include "messy.h" #include <bits/stdc++.h> #define x first #define y second using namespace std; typedef long long ll; typedef pair <ll,ll> pi; typedef vector <int> vec; const ll INF = 1e18; int n; vec ans; void build(int l,int r) { if(l == r) return; int mid = (l + r) >> 1; string p; for(int i = 0;i < l;i++) p += "1"; for(int i = l;i <= r;i++) p += "0"; for(int i = r+1;i < n;i++) p += "1"; for(int i = l;i <= mid;i++) { p[i] = '1'; //cout << p << '\n'; add_element(p); p[i] = '0'; } build(l,mid), build(mid+1,r); } void go(vec x,int l,int r) { if(l == r) { ans[x[0]] = l; return; } string p; for(int i = 0;i < n;i++) p += "1"; for(int i : x) p[i] = '0'; vec ne[2]; for(int i : x) { p[i] = '1'; ne[(int)check_element(p)].push_back(i); p[i] = '0'; } int mid = (l + r) >> 1; go(ne[1],l,mid), go(ne[0],mid+1,r); } vec restore_permutation(int N,int w,int r) { n = N; build(0,n-1); compile_set(); ans.resize(n); vec tmp; for(int i = 0;i < n;i++) tmp.push_back(i); go(tmp,0,n-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...