Submission #295335

#TimeUsernameProblemLanguageResultExecution timeMemory
295335KastandaMechanical Doll (IOI18_doll)C++11
0 / 100
3 ms460 KiB
// M #include<bits/stdc++.h> #include "doll.h" using namespace std; const int N = 400005; int n, m, A[N], L[N], R[N]; void create_circuit(int _m, vector < int > _A) { m = _m; n = (int)_A.size(); for (int i = 0; i < n; i ++) A[i] = _A[i]; A[n] = 0; assert(n <= 9); int k = 0; while ((1 << k) < n) k ++; int len = (1 << k) - 1; vector < pair < int , int > > vec; for (int i = 1; i <= len; i ++) { if (i * 2 + 1 <= len) L[i] = -(i * 2), R[i] = -(i * 2 + 1); else { int ra = 0, a = i; while (a) ra = (ra << 1) | (a & 1), a >>= 1; vec.push_back({ra | (1 << k), i}); vec.push_back({ra, i}); } } sort(vec.begin(), vec.end()); int dummy = (int)vec.size() - n; for (int i = 0; i < dummy; i ++) { int id = vec[i].second; int a = vec[i].first; if ((a >> k) & 1) R[id] = -1; else L[id] = -1; } for (int i = dummy; i < (int)vec.size(); i ++) { int j = A[i - dummy + 1]; int id = vec[i].second; int a = vec[i].first; if ((a >> k) & 1) R[id] = j; else L[id] = j; } vector < int > C(m + 1, -1); C[0] = A[0]; vector < int > X(len), Y(len); for (int i = 0; i < len; i ++) X[i] = L[i + 1], Y[i] = R[i + 1]; assert(len <= n + n); answer(C, X, Y); return ; }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...