제출 #784073

#제출 시각아이디문제언어결과실행 시간메모리
784073zsomborUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
2 ms512 KiB
#include <iostream> #include <vector> #include "messy.h" using namespace std; string s = ""; char opp(int i) { return (s[i] == '0' ? '1' : '0'); } vector <int> restore_permutation(int n, int w, int r) { int l = 0; while ((n & (1 << l)) == 0) l++; for (int i = 0; i < n; i++) s.push_back('0'); for (int i = 1; i < n; i += 2) { s[i] = '1'; add_element(s); s[i] = '0'; } for (int j = 1; j < l; j++) { for (int i = 0; i < n; i++) s[i] = (i & (1 << (j - 1))) ? '1' : '0'; for (int i = 0; i < n; i++) { if ((i & (1 << j)) == 0) continue; s[i] = opp(i); add_element(s); s[i] = opp(i); } } compile_set(); fill(s.begin(), s.end(), '0'); vector <vector <bool>> b(n, vector <bool>(l, false)); for (int i = 0; i < n; i++) { s[i] = '1'; b[i][0] = check_element(s); s[i] = '0'; } for (int j = 1; j < l; j++) { for (int i = 0; i < n; i++) s[i] = b[i][j - 1] ? '1' : '0'; for (int i = 0; i < n; i++) { s[i] = opp(i); b[i][j] = check_element(s); s[i] = opp(i); } } vector <int> ans(n, 0); for (int i = 0; i < n; i++) { for (int j = 0; j < l; j++) { if (b[i][j]) ans[i] += (1 << j); } } 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...