제출 #421556

#제출 시각아이디문제언어결과실행 시간메모리
421556Peti자동 인형 (IOI18_doll)C++14
16 / 100
255 ms16440 KiB
#include <bits/stdc++.h> #include "doll.h" using namespace std; std::vector<int> X, Y; int add_switch(){ X.push_back(0); Y.push_back(0); return (int)X.size()-1; } void set_child(int x, int l, int r){ X[x] = l; Y[x] = r; } int add(int x, vector<int> &v){ int ret = 0; if(v.size() == 2){ ret = add_switch(); set_child(ret, v[0], v[1]); } else{ ret = add_switch(); int l = add_switch(), r = add_switch(); set_child(ret, -l-1, -r-1); if(v.size() == 3){ set_child(l, -ret-1, v[1]); set_child(r, v[0], v[2]); }else{ set_child(l, v[0], v[2]); set_child(r, v[1], v[3]); } } return -ret-1; } void create_circuit(int M, std::vector<int> A) { int N = A.size(); map<int, vector<int>> kov; kov[0].push_back(A[0]); for(int i = 0; i < N; i++){ if(i < N-1){ kov[A[i]].push_back(A[i+1]); } else kov[A[i]].push_back(0); } std::vector<int> C(M + 1, 0); for(auto d : kov){ //cout<<d.second.size()<<" "<<d.first<<"\n"; if(d.second.size() == 1){ C[d.first] = d.second[0]; } else C[d.first] = add(d.first, d.second); } //for(int i = 0; i < M+1; i++) //cout<<i<<" -> "<<C[i]<<"\n"; 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...