| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1366363 | ahmdnawaz | September (APIO24_september) | C++20 | 0 ms | 344 KiB |
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define all(x) (x).begin(), (x).end()
using ll = int64_t;
int solve(int N, int M, vector<int> F, vector<vector<int>> S) {
vector<int> vals;
vector<int> par = F;
vector<int> deg(N, 0);
for (int i = 1; i < N; i++) {
deg[i]++;
deg[F[i]]++;
}
for (int i = 1; i < N; i++)
deg[i]--;
vector<vector<bool>> good(M, vector<bool> (N - 1));
for (int i = 0; i < M; i++) {
vector<int> Deg = deg;
set<int> s;
int j = 0;
for (int node : S[i]) {
if (Deg[node] == 0) {
while (1) {
if (node == 0) break;
Deg[par[node]]--;
if (Deg[par[node]] > 0) break;
if (s.count(par[node])) {
s.erase(par[node]);
} else {
break;
}
node = par[node];
}
} else {
s.insert(node);
}
if (s.empty())
good[i][j] = true;
j++;
}
}
int ans = 0;
for (int i = 0; i < N - 1; i++) {
bool ok = true;
for (int j = 0; j < M; j++) {
ok = ok || good[i][j];
}
ans += ok;
}
return ans;
}
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
