# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1092369 | raphaelp | September (APIO24_september) | C++17 | 124 ms | 15352 KiB |
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 <bits/stdc++.h>
using namespace std;
int solve(int N, int M, vector<int> F, vector<vector<int>> S)
{
vector<int> inv(N);
vector<vector<int>> AR(N);
for (int i = 0; i < N - 1; i++)
{
AR[F[i + 1]].push_back(i + 1);
for (int j = 0; j < M; j++)
{
inv[S[j][i]] = max(inv[S[j][i]], i);
}
}
int ans = 0, next = 0;
for (int i = 0; i < N - 1; i++)
{
int x = S[0][i];
next = max(next, inv[x]);
for (int j = 0; j < AR[x].size(); j++)
{
next = max(next, inv[AR[x][j]]);
}
if (next == i)
ans++;
}
return ans;
}
/*int main()
{
int N, M;
cin >> N >> M;
vector<int> p(N);
vector<vector<int>> S(M, vector<int>(N - 1));
for (int i = 0; i < N; i++)
cin >> p[i];
for (int i = 0; i < M; i++)
{
for (int j = 0; j < N - 1; j++)
{
cin >> S[i][j];
}
}
cout << solve(N, M, p, S);
}*/
Compilation message (stderr)
# | 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... |