This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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,m = M;
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++) {
for(int j = 0; j < m; j++) {
p[S[j][i]] = max(p[S[j][i]],i);
}
}
int y = 0,ans = 0;
for(int i = 0; i < n-1; i++) {
for(int j = 0; j < m; j++) {
int a = S[j][i];
y = max(y,p[a]);
for(int v: haha[a]) {
y = max(y,p[v]);
}
}
if(y <= i) {
ans++;
}
}
return ans;
}
# | 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... |