Submission #286225

#TimeUsernameProblemLanguageResultExecution timeMemory
286225ne4eHbKaMechanical Doll (IOI18_doll)C++17
0 / 100
1 ms204 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; typedef vector<int> vi; namespace solution { vi c, x, y; int s; vector<bool> e; int generate_switch(int p) { int i = s++; x.push_back(0); y.push_back(0); e.push_back(false); if(p) { x[i] = generate_switch(p - 1); y[i] = generate_switch(p - 1); } return -(i + 1); } void set_exit(int p, int v, int i = 0) { int &j = (e[i] ? y : x)[i]; e[i] = !e[i]; if(p) { set_exit(p - 1, v, -(j + 1)); } else { j = v; } } } void create_circuit (int m, vi a) { using namespace solution; int n = a.size(); s = 0; c.resize(m + 1); e.clear(); x.clear(); y.clear(); int p = 0; for(; 1 << p < n; ++p); c[0] = a[0]; fill(c.begin(), c.end(), generate_switch(p)); int u = 1 << p; for(int i = 1; i < n; ++i) { --u; set_exit(p, a[i]); } while(u > 1) { --u; set_exit(p, -1); } set_exit(p, 0); 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...