제출 #293284

#제출 시각아이디문제언어결과실행 시간메모리
293284MoNsTeR_CuBeUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms512 KiB
#include <vector> #include <bits/stdc++.h> #include "messy.h" using namespace std; vector< int > ans; int n; void build(int left, int right){ if(left == right) return; int mid = (left+right)/2; string v(n,'1'); for(int i = left; i <= right; i++){ v[i] = '0'; } for(int i = left; i <= mid; i++){ v[i] = '1'; add_element(v); v[i] = '0'; } build(left, mid); build(mid+1, right); } void answer(int left, int right, vector< int > available){ if(left == right){ if(available.size() != 0) ans[available[0]] = left; return; } string v(n,'1'); int mid = (left+right)/2; for(int a : available) v[a] = '0'; vector< int > L; vector< int > R; for(int a : available){ v[a] = '1'; if(check_element(v)){ L.push_back(a); }else{ R.push_back(a); } v[a] = '0'; } answer(left, mid, L); answer(mid+1, right, R); } std::vector<int> restore_permutation(int N, int w, int r) { n = N; build(0,n-1); compile_set(); ans.resize(n); vector< int > v(n); for(int i = 0; i < n; i++){ v[i]=i; } answer(0,n-1,v); //for(int a : ans) cout << a << ' '; //cout << endl; 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...