#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |