#include "september.h"
#include <bits/stdc++.h>
using namespace std;
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S)
{
vector<vector<int>> graph(N);
for (int i = 1; i < N; i++)
{
graph[F[i]].push_back(i);
}
int boundary = 0;
vector<map<int, int>> cache(M);
for (int i = 0; i < N; i++)
{
for (int v = 0; v < M; v++)
{
cache[v][S[v][i]] = i;
}
}
int res = 0;
for (int i = 0; i < N-1; i++)
{
boundary = max(boundary, i);
for (int v = 0; v < M; v++)
{
for (int w = 0; w < M; w++)
{
boundary = max(boundary, cache[v][S[v][i]]);
}
for (auto c : graph[S[v][i]])
{
for (int w = 0; w < M; w++)
{
boundary = max(boundary, cache[w][c]);
}
}
}
if (boundary == i)
{
res++;
}
}
return res;
}
# | 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... |