제출 #601562

#제출 시각아이디문제언어결과실행 시간메모리
601562Mazaalai자동 인형 (IOI18_doll)C++17
37 / 100
173 ms13260 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; VI c, x, y, state; int switchNo = 1; bool vis; int generate(int l, int r) { if (l == r) { return (r+n < p ? -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); // cout << curNode << ": " << x[curNode] << ',' << y[curNode] << " -> " << l << ' ' << r << '\n'; return -curNode; } bool last; 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; last = v; c[v] = -1; return; } return addPos(nx, v); } void create_circuit(int M, vector<int> nums) { m = M; n = sz(nums); c = VI(m+1, 0); while(p <= n) p *= 2; x = VI(2*p, 0); y = VI(2*p, 0); state = VI(2*p, 0); generate(1, p); c[0] = -1; for (int i = 0; i < n; i++) { addPos(-1, nums[i]); } x.resize(switchNo); y.resize(switchNo); reverse(ALL(x)); reverse(ALL(y)); x.pop_back(); y.pop_back(); reverse(ALL(x)); reverse(ALL(y)); // cout << "C: "; // for (int i = 0; i < m; i++) cout << c[i] << " \n"[i==m-1]; // cout << "XY: "; // for (int i = 0; i < sz(x); i++) cout << x[i] << ',' << y[i] << " \n"[i==sz(x)-1]; 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...