# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1078228 | Marco_Escandon | September (APIO24_september) | C++17 | 165 ms | 13756 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;
typedef int ll;
#define x first
#define y second
vector<ll> temp,p;
vector<vector<ll>> G;
ll dfs(ll node)
{
ll asd=temp[node];
for(auto i:G[node])
asd=max(asd,dfs(i));
p[node]=asd;
return asd;
}
vector<ll> calc(ll n, vector<ll> cad)
{
for(int i=0; i<cad.size(); i++)
temp[cad[i]]=i;
dfs(0);
return p;
}
int solve(int n, int m, std::vector<int> F, std::vector<std::vector<int>> S) {
G.clear();temp.clear();p.clear();
G.resize(n+2);temp.resize(n+2);p.resize(n+2);
for(int i=1; i<n; i++)
G[F[i]].push_back(i);
p=calc(n,S[0]);
ll a=-1,cont=0;
for(int i=0; i<S[0].size(); i++)
{
if(i>a) cont++;
a=max(p[S[0][i]],a);
}
return cont;
}
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... |