이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define vll vector<ll>
#define pll pair<ll,ll>
#define F first
#define S second
#define MAX 500005
vll v[MAX];
ll a[MAX];
ll mn[MAX],mx[MAX];
int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) {
for(int i=0;i<N;i++){
v[i]={};a[i]=i;
}
for(int i=1;i<N;i++){
v[F[i]].push_back(i);
}
for(int j=0;j<M;j++){
map<ll,ll> mp;
for(int i=0;i<N-1;i++){
mp[S[j][i]]=i;
mn[S[j][i]]=min(mn[S[j][i]],(ll)i);
mx[S[j][i]]=max(mx[S[j][i]],(ll)i);
}
for(int i=0;i<N-1;i++){
for(auto u : v[S[j][i]]){
a[i]=max(a[i],mp[u]);
}
}
}
for(int i=1;i<N-1;i++){
a[mn[i]]=max(mx[i],a[mn[i]]);
}
ll K=0;ll limit=0;
for(int i=0;i<N-1;i++){
//cout<<a[i]<<
limit=max(limit,a[i]);
if(limit==i)K++;
}
return K;
}
# | 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... |