제출 #791035

#제출 시각아이디문제언어결과실행 시간메모리
791035khshgUnscrambling a Messy Bug (IOI16_messy)C++14
0 / 100
3 ms812 KiB
#include"messy.h" #include<bits/stdc++.h> using namespace std; vector<int> restore_permutation(int N, int W, int R) { int B = __lg(N); for(int i = 0; i < B; ++i) { string S(N, '0'); for(int j = 0; j <= i; ++j) { S[j] = '1'; } add_element(S); } for(int i = B - 1; i >= 0; --i) { string S(N, '0'); S[B - i - 1] = '1'; for(int j = B; j < N; ++j) { if(j % (1 << (i + 1)) < (1 << i)) { S[j] = '1'; add_element(S); S[j] = '0'; } } } compile_set(); vector<int> P(N, -1); for(int i = 0; i < B; ++i) { string S(N, '0'); for(int j = 0; j < i; ++j) S[P[j]] = '1'; for(int j = 0; j < N; ++j) { if(S[j] == '1') continue; S[j] = '1'; if(!check_element(S)) { S[j] = '0'; continue; } P[i] = j; break; } } string og(N, '0'); for(int i = 0; i < B; ++i) og[P[i]] = '1'; for(int i = 0; i < N; ++i) { if (og[i] == '1') continue; int k = 0; string S(N, '0'); S[i] = '1'; for(int j = 0; j < B; ++j) { S[P[j]] = '1'; if (!check_element(S)) { k += 1 << (B - j - 1); } S[P[j]] = '0'; } P[k] = i; } vector<int> ans(N); for(int i = 0; i < N; ++i) { ans[P[i]] = i; } 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...