제출 #791186

#제출 시각아이디문제언어결과실행 시간메모리
791186enerelt14Unscrambling a Messy Bug (IOI16_messy)C++14
70 / 100
1 ms468 KiB
#include "messy.h" #include <algorithm> #include <array> #include <bitset> #include <cassert> #include <chrono> #include <climits> #include <cmath> #include <complex> #include <cstring> #include <functional> #include <iomanip> #include <iostream> #include <map> #include <numeric> #include <queue> #include <random> #include <set> #include <vector> using namespace std; vector<int> restore_permutation(int n, int w, int r) { int x = __lg(n); for(int i = 0; i < x; i++) { string S(n, '0'); for(int j = 0; j <= i; j++) { S[j] = '1'; } add_element(S); } for(int i = 0; i < x; i++) { string S(n, '1'); S[i] = '0'; for(int j = x; j < n; j++) { if(j & (1 << i)) continue; S[j] = '0'; add_element(S); S[j] = '1'; } } compile_set(); vector<int> ans(n, -1), p(n, -1); for(int i = 0; i < x; i++) { string S(n, '0'); for(int j = 0; j < n; j++) { if(ans[j] == -1) continue; S[j] = '1'; } for(int j = 0; j < n; j++) { if(ans[j] != -1) continue; S[j] = '1'; if(!check_element(S)) { S[j] = '0'; continue; } ans[j] = i; p[i] = j; break; } } for(int i = 0; i < n; i++) { if(ans[i] != -1) continue; ans[i] = 0; string S(n, '1'); S[i] = '0'; for(int j = 0; j < x; j++) { S[p[j]] = '0'; if(!check_element(S)) { ans[i] += (1 << j); } S[p[j]] = '1'; } } 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...