Submission #1203914

#TimeUsernameProblemLanguageResultExecution timeMemory
1203914speedcodeSeptember (APIO24_september)C++20
100 / 100
637 ms34084 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-1; 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[w][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...