제출 #962391

#제출 시각아이디문제언어결과실행 시간메모리
962391PoPularPlusPlusUnscrambling a Messy Bug (IOI16_messy)C++17
0 / 100
2 ms1116 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; #define pb(x) push_back(x) vector<int> ans; int n; void put(int l , int r){ if(l == r - 1)return; int m = (l + r)/2; string s = ""; for(int i = 0; i < n; i++){ s += '1'; } for(int i = l; i < r; i++){ s[i] = '0'; } for(int i = l; i < m; i++){ s[i] = '1'; add_element(s); s[i] = '0'; } add_element(s); put(l , m); put(m , r); } void solve(vector<int>& v , int l , int r){ //cout << l << ' ' << r << ' ' << v.size() << endl; if(l == r - 1){ ans[l] = v[0]; return; } int m = (l + r)/2; string s = ""; for(int i = 0; i < n; i++)s += '1'; for(int i = l; i < r; i++){ s[i] = '0'; } vector<int> a , b; for(int i = l; i < r; i++){ s[i] = '1'; if(check_element(s)){ a.pb(i); } else b.pb(i); s[i] = '0'; } assert(a.size() == b.size()); solve(a , l , m); solve(b,m,r); } vector<int> restore_permutation(int nn, int w, int r){ n = nn; ans.resize(n); put(0 , n); compile_set(); vector<int> cur; for(int i = 0; i < n; i++){ cur.pb(i); } solve(cur , 0 , n); //cout << "came" << endl; /*for(int i = 0; i < n; i++){ cout << ans[i] << 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...