제출 #1078255

#제출 시각아이디문제언어결과실행 시간메모리
1078255Maite_Morale9월 (APIO24_september)C++17
0 / 100
6 ms12120 KiB
#include <bits/stdc++.h> using namespace std; typedef long long ll; #define vll vector<ll> #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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...