# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
999845 | AMel0n | September (APIO24_september) | C++17 | 154 ms | 13624 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;
#define endl '\n'
#define rep(a) for(int i=0;i<a;++i)
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define node S[i][j]
int solve(int N, int M, std::vector<int> P, std::vector<std::vector<int>> S) {
// vi CHILDREN(N);
// for(int i=1; i<N; ++i) {
// CHILDREN[P[i]]++;
// }
vector<vector<int>> um(M,vector<int>(N,-1));
vector<pi> ranges(N, pi(-1,-1));
rep(M) {
for(int j=0; j<N - 1; ++j) {
if (ranges[node].first == -1) {
ranges[node].first = j;
} else if (ranges[node].second == -1) {
ranges[node].second = j;
} else if (ranges[node].second < j) {
ranges[node].second = j;
}if (um[i][P[node]] != -1) {
ranges.push_back({um[i][P[node]],j});
}
um[i][node]=j;
}
}
sort(ranges.begin(), ranges.end());
int res = 0, l = 0, r = 0, i = 0;
while (l < N - 1){
while (i < ranges.size() && ranges[i].first <= r){
r = max(r, ranges[i].second); i++;
}
res++;
l = r + 1; r++;
}
return res;
}
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... |