제출 #481255

#제출 시각아이디문제언어결과실행 시간메모리
481255HamletPetrosyanUnscrambling a Messy Bug (IOI16_messy)C++17
20 / 100
2 ms460 KiB
#include <bits/stdc++.h> using namespace std; #include "messy.h" int n, w, r; vector<int> res; void add_all_elements(int l, int r){ if(l == r) return; string s(n, '1'); for(int i = l; i <= r; i++) { s[i] = '0'; } int mid = (l + r) / 2; for(int i = l; i <= mid; i++){ s[i] = '1'; add_element(s); s[i] = '0'; } add_all_elements(l, mid); add_all_elements(mid + 1, r); } void get_positions(int l, int r, string s){ string now = s; for(int i = 0; i < n; i++){ if(s[i] == '0'){ s[i] = '1'; if(check_element(s)){ now[i] = '1'; } s[i] = '0'; } } // cout << s << " | " << now << endl; if(l == r - 1){ for(int i = 0; i < n; i++){ if(now[i] != s[i]){ res[l] = i; } if(now[i] == '0'){ res[r] = i; } } // cout << l << " " << r << " " << res[l] << " " << res[r] << endl; return; } int mid = (l + r) / 2; get_positions(mid + 1, r, now); for(int i = 0; i < n; i++){ if(s[i] != now[i]){ now[i] = '0'; } else { now[i] = '1'; } } get_positions(l, mid, now); } vector<int> restore_permutation(int N, int W, int R) { n = N, w = W, r = R; res = vector<int>(n, 0); add_all_elements(0, n - 1); compile_set(); get_positions(0, n - 1, string(n, '0')); 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...