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;
using ll = long long;
int solve(int N, int M, vector<int> P, vector<vector<int>> S) {
vector<int> pos(N), mx(N);
for (int i = 0; i < N - 1; i++) {
pos[S[0][i]] = mx[S[0][i]] = i;
}
for (int i = N - 1; i; i--) {
mx[P[i]] = max(mx[P[i]], pos[i]);
}
int ans = 0;
for (int i = 0, j = -1; i < N - 1; i++) {
if ((j = max(j, mx[S[0][i]])) == i) ans++, j = -1;
}
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... |