제출 #1123424

#제출 시각아이디문제언어결과실행 시간메모리
1123424LucaLucaM9월 (APIO24_september)C++20
59 / 100
180 ms10596 KiB
#include "september.h" #include <vector> #include <algorithm> #include <iostream> #define debug(x) #x << " = " << x << '\n' int solve(int n, int m, std::vector<int> parent, std::vector<std::vector<int>> s) { std::vector<bool> ok(n - 1, true); std::vector<std::vector<int>> sons(n); for (int i = 1; i < n; i++) { sons[parent[i]].push_back(i); } for (const auto &a : s) { std::vector<bool> alive(n, true); int cur = n - 1; for (int i = 0; i < n - 1; i++) { // daca sterg nodurile 0..i atunci cate noduri u am a.i. si u si parent[u] sunt vii? int u = a[i]; // std::cout << debug(u) << ' ' << debug(parent[u]); if (alive[parent[u]]) { cur--; } for (const auto &v : sons[u]) { if (alive[v]) { cur--; } } alive[u] = false; if (cur != n - 2 - i) { ok[i] = false; } } } return std::count(ok.begin(), ok.end(), true); }
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...