제출 #1203905

#제출 시각아이디문제언어결과실행 시간메모리
1203905speedcode9월 (APIO24_september)C++20
0 / 100
1 ms324 KiB
#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 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...