Submission #1000109

#TimeUsernameProblemLanguageResultExecution timeMemory
1000109AndreySeptember (APIO24_september)C++17
45 / 100
106 ms13740 KiB
#include "september.h" #include<bits/stdc++.h> using namespace std; vector<int> haha[200001]; int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { int n = N; for(int i = 0; i <= n; i++) { haha[i].clear(); } for(int i = 1; i < n; i++) { haha[F[i]].push_back(i); } vector<int> p(n+1); for(int i = 0; i < n-1; i++) { p[S[0][i]] = i; } int y = 0,ans = 0; for(int i = 0; i < n-1; i++) { int a = S[0][i]; for(int v: haha[a]) { y = max(y,p[v]); } if(y <= i) { ans++; } } return ans; }
#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...