제출 #477231

#제출 시각아이디문제언어결과실행 시간메모리
477231ponytailUnscrambling a Messy Bug (IOI16_messy)C++17
100 / 100
4 ms596 KiB
#include <bits/stdc++.h> #include "messy.h" using namespace std; int fastlog(int n) { return 32 - __builtin_clz(n) - 1; } std::vector<int> restore_permutation(int n, int w, int r) { vector<int> p(n); string empty; for(int i=0; i<n; i++) empty += '0'; for(int i=1; i<n; i+=2) { empty[i] = '1'; add_element(empty); empty[i] = '0'; } for(int i=1; i<fastlog(n); i++) { for(int j=0; j<n; j++) { if((j&(1<<i)) != 0) { int v = j % (1<<i); v = (1<<i) - 1 - v; for(int k=0; k<n; k++) { if(k % (1<<i) == v % (1<<i)) { empty[k] = '1'; } } empty[j] = '1'; add_element(empty); for(int k=0; k<n; k++) { empty[k] = '0'; } } } } compile_set(); for(int i=0; i<n; i++) { empty[i] = '1'; if(check_element(empty)) { p[i]++; } empty[i] = '0'; } for(int i=1; i<fastlog(n); i++) { for(int j=0; j<n; j++) { int v = (1<<i) - 1 - p[j]; for(int k=0; k<n; k++) { if(p[k] % (1<<i) == v % (1<<i)) { empty[k] = '1'; } } empty[j] = '1'; if(check_element(empty)) { p[j] += (1<<i); } for(int k=0; k<n; k++) { empty[k] = '0'; } } } return p; }
#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...