제출 #1121640

#제출 시각아이디문제언어결과실행 시간메모리
1121640vjudge1Unscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
3 ms760 KiB
#include <vector> #include <bits/stdc++.h> #include "messy.h" using namespace std; const int MAX = 130; void write(int l, int r, int n){ if(l == r) return; string s = ""; for(int i = 0; i < n; i++){ if(l <= i && i <= r){ s += '0'; } else{ s += '1'; } } int mid = (l + r) / 2; for(int i = l; i <= mid; i++){ s[i] = '1'; add_element(s); s[i] = '0'; } write(l, mid, n); write(mid + 1, r, n); } int p[MAX]; void read(int l, int r, vector<int> inc, int n){ if(l == r){ p[inc[0]] = l; return; } string s = ""; for(int i = 0; i < n; i++){ s += '1'; } for(int a : inc){ s[a] = '0'; } int mid = (l + r) / 2; vector<int> lv, rv; for(int i : inc){ s[i] = '1'; if(check_element(s)){ lv.push_back(i); } else{ rv.push_back(i); } s[i] = '0'; } read(l, mid, lv, n); read(mid + 1, r, rv, n); } vector<int> restore_permutation(int n, int w, int r) { write(0, n - 1, n); compile_set(); vector<int> tmp; for(int i = 0; i < n; i++) tmp.push_back(i); read(0, n - 1, tmp, n); vector<int> res; for(int i = 0; i < n; i++){ res.push_back(p[i]); } 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...