Submission #1244745

#TimeUsernameProblemLanguageResultExecution timeMemory
1244745JoenPoenManMechanical Doll (IOI18_doll)C++20
53 / 100
84 ms13224 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; int makeswitch(vi &outs, vi &x, vi &y) { if(outs.size() == 1) return outs[0]; int switchindex = -x.size() - 1; x.push_back(0); y.push_back(0); if(outs.size() % 2 == 1) { outs.insert(outs.end() - 2, switchindex); } vi a, b; for(int i = 0; i < outs.size(); i += 2) { a.push_back(outs[i]); b.push_back(outs[i+1]); } x[-switchindex-1] = makeswitch(a, x, y); y[-switchindex-1] = makeswitch(b, x, y); return switchindex; } void create_circuit(int m, vi a) { int n = a.size(); vvi next(m+1); next[0].push_back(a[0]); for(int i = 1; i < n; i++) { next[a[i-1]].push_back(a[i]);/* */ } next[a[n-1]].push_back(0); vi c(m+1), x, y; for(int i = 0; i < m + 1; i++) { if(next[i].empty()) continue; c[i] = makeswitch(next[i], x, y); } 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...