| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1368493 | idonoam | September (APIO24_september) | C++17 | 111 ms | 10868 KiB |
#include "september.h"
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S)
{
vector<vector<int>> sons(N);
for (int i = 1; i < N; i++)
{
sons[F[i]].push_back(i);
}
vector<int> vis(N, 0);
int op = 0, z = 0;
for (int i = 0; i < N - 1; i++)
{
for (int k = 0; k < M; k++)
{
if (!z)
op++;
if (vis[S[k][i]])
z--;
else
{
z+=(M-1);
vis[S[k][i]] = M;
stack<int> st;
st.push(S[k][i]);
while (st.size())
{
int c = st.top();
st.pop();
for (int j = 0; j < sons[c].size(); j++)
{
if (!vis[sons[c][j]])
{
z += M;
st.push(sons[c][j]);
vis[sons[c][j]] = M;
}
}
}
}
}
}
return op;
}
| # | 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... | ||||
