Submission #75481

#TimeUsernameProblemLanguageResultExecution timeMemory
75481sevenkplusMechanical Doll (IOI18_doll)C++14
47 / 100
140 ms8500 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef pair<int, int> PII; #define fi first #define se second #define pb push_back #define mp make_pair #define pct __builtin_popcount #define INF 1000000007 void create_circuit(int m, vector<int> a) { int n = a.size(); a.pb(0); vector<int> sc(m + 1, 0); sc[0] = a[0]; if (n == 1) { answer(sc, {}, {}); return; } for (int i = 1; i <= m; i ++) sc[i] = -1; int p = 1; while (p < n) p *= 2; vector<int> wx(p-1, INF); vector<int> wy(p-1, INF); vector<bool> t(p-1, 0); for (int i = 0; i < p/2-1; i ++) { wx[i] = -(i*2+1 +1); wy[i] = -(i*2+2 +1); } for (int i = 0; i < p; i ++) { int x = 0; while (x < p-1) { if (t[x] == 1) { t[x] = 0; x = x*2+2; } else { t[x] = 1; x = x*2+1; } } int ne = -1; if (i >= p-n) ne = a[i-(p-n)+1]; if (x%2) wx[(x-1)/2] = ne; else wy[(x-1)/2] = ne; } answer(sc, wx, wy); }
#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...