제출 #172984

#제출 시각아이디문제언어결과실행 시간메모리
172984nobik자동 인형 (IOI18_doll)C++14
6 / 100
119 ms11044 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]); } outs[A[n - 1]].push_back(0); for (int i = 0; i < M + 1; ++i) { if (!outs[i].empty()) { while (outs[i].size() & ((int) outs[i].size() - 1)) outs[i].push_back(0); 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...