Submission #172981

#TimeUsernameProblemLanguageResultExecution timeMemory
172981nobikMechanical Doll (IOI18_doll)C++14
2 / 100
73 ms7720 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; int BuildTree(const vector<int>& outs, vector<int>& x, vector<int>& y) { if (outs.size() == 1) { return outs[0]; } vector<int> left, right; for (int i = 0; i < (int) outs.size(); ++i) { if (i % 2 == 0) left.push_back(outs[i]); else right.push_back(outs[i]); } int id_left = BuildTree(left, x, y); int id_right = BuildTree(right, x, y); x.push_back(id_left); y.push_back(id_right); return -(int)x.size(); } void create_circuit(int M, std::vector<int> A) { int n = A.size(); vector<vector<int>> outs(M + 1); outs[0].push_back(A[0]); std::vector<int> C(M + 1); vector<int> X, Y; for (int i = 0; i < n; ++i) { if (i + 1 < n) outs[A[i]].push_back(A[i + 1]); } for (int i = 0; i < M + 1; ++i) { if (!outs[i].empty()) C[i] = BuildTree(outs[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...