제출 #605696

#제출 시각아이디문제언어결과실행 시간메모리
605696jairRSMechanical Doll (IOI18_doll)C++17
6 / 100
79 ms11324 KiB
#include "doll.h" #include <bits/stdc++.h> using namespace std; using vi = vector<int>; using vvi = vector<vi>; void create_circuit(int M, vi A) { int N = A.size(), S = 0; A.push_back(0); vi C(M + 1), X(S), Y(S); auto addSwitch = [&S, &X, &Y](int x, int y) { S++; X.push_back(x); Y.push_back(y); return -S; }; vvi toMap(M + 1, vi()); toMap[0].push_back(A[0]); for (int i = 0; i < N; i++) toMap[A[i]].push_back(A[i + 1]); for (int trg = 0; trg <= M; trg++) { vi &endpoints = toMap[trg]; if (endpoints.size() == 1) C[trg] = endpoints[0]; if (endpoints.size() == 2) C[trg] = addSwitch(endpoints[0], endpoints[1]); if (endpoints.size() >= 3) { // 0 2 1 3 int bottom1 = addSwitch(endpoints[0], endpoints[2]); int bottom2 = addSwitch(endpoints.size() == 3 ? -(S + 1) : endpoints[1], endpoints[3]); C[trg] = addSwitch(bottom1, bottom2); } } 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...