Submission #286180

#TimeUsernameProblemLanguageResultExecution timeMemory
286180ne4eHbKaMechanical Doll (IOI18_doll)C++17
6 / 100
326 ms19592 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; namespace solution { map<int, list<int> > f; vi c, x, y; int s; int swicch(list<int> &t) { int i = s++; x.push_back(0); y.push_back(0); list<int> a, b; int cnt = 0; for(int &j : t) (cnt++ & 1 ? b : a).push_back(j); x[i] = a.size() - 1 ? swicch(a) : a.front(); y[i] = b.size() - 1 ? swicch(b) : b.front(); return -(i + 1); } void trigger(int i) { if(f.find(i) == f.end()) { c[i] = 0; return; } list<int> &t = f[i]; if(t.size() == 1) { c[i] = t.front(); return; } c[i] = swicch(t); } } void create_circuit (int m, vi a) { using namespace solution; int n = a.size(); f.clear(); for(int i = 1; i < n; ++i) f[a[i - 1]].push_back(a[i]); f[a.back()].push_back(0); c.resize(m + 1); x.clear(); y.clear(); s = 0; c[0] = a.front(); for(int i = 1; i <= m; ++i) trigger(i); 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...