Submission #601592

#TimeUsernameProblemLanguageResultExecution timeMemory
601592MazaalaiMechanical Doll (IOI18_doll)C++17
0 / 100
20 ms7268 KiB
#include "doll.h" #include <bits/stdc++.h> #define sz(x) (int)x.size() #define ALL(x) x.begin(), x.end() #define pb push_back #define ff first #define ss second using namespace std; using VI = vector <int>; using PII = pair <int, int>; int n, m, p = 1; const int N = 2e5; VI c, x(N), y(N), state(N); int switchNo = 1; bool vis; int generate(int l, int r) { if (l == r) { /* n+1 down, others up int lim = p-n-1 */ return (r <= p-n-1 ? -1 : 0); // not switch // makes n+1 zero } int mid = (l+r)>>1, curNode = switchNo++; x[curNode] = generate(l, mid); y[curNode] = generate(mid+1, r); return -curNode; } void addPos(int pos, int v) { // removes n zero int& nx = (state[-pos] ? y[-pos] : x[-pos]); state[-pos] ^= 1; if (nx == 0) { nx = v; // cout << "ADD: " << v << '\n'; return; } return addPos(nx, v); } void create_circuit(int M, vector<int> nums) { m = M; n = sz(nums); c = VI(m+1, -1); while(p < n+1) p *= 2; nums.pb(0); generate(1, p); for (int i = 0; i <= n; i++) addPos(-1, nums[i]); for (int i = 0; i < switchNo-1; i++) { x[i] = x[i+1]; y[i] = y[i+1]; } x.resize(switchNo-1); y.resize(switchNo-1); // for (int i = 0; i < sz(x); i++) cout << i+1 << ": " << x[i] << ',' << y[i] << '\n'; answer(c, x, y); }
#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...