# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
993477 | ramalzaher | September (APIO24_september) | C++17 | 165 ms | 18024 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 "september.h"
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
vector<int> g[N];
int value[N];
void dfs(int node) {
for(int to: g[node]) {
dfs(to);
value[node] = max(value[node], value[to]);
}
}
int solve(int N, int M, vector<int> F, vector<vector<int>> S) {
for(int i = 0; i <= N; i++) {
g[i].clear();
value[i] = 0;
}
for(int i = 1; i < N; i++) {
g[F[i]].push_back(i);
}
for(int i = 0; i < M; i++) {
for(int j = 0; j < N - 1; j++) {
value[S[i][j]] = max(value[S[i][j]], j + 1);
}
}
dfs(0);
vector<int> values;
for(int i = 1; i < N; i++) {
values.push_back(value[i]);
}
sort(values.begin(), values.end());
// for(int i: values) {
// cout << i << " ";
// }
// cout << "\n";
int pos = 0;
int cnt = 0;
for(int i = 1; i < N; i++) {
while(pos != values.size() && values[pos] == i) {
pos += 1;
}
if(i == pos) {
cnt += 1;
}
}
return cnt;
}
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... |