Submission #996663

#TimeUsernameProblemLanguageResultExecution timeMemory
996663aintaSeptember (APIO24_september)C++17
100 / 100
107 ms13516 KiB
#include "september.h" #include <vector> #include <bits/stdc++.h> using namespace std; #define rng(i,a,b) for(int i=int(a);i<=int(b);i++) #define rep(i,b) rng(i,0,b-1) #define gnr(i,b,a) for(int i=int(b);i>=int(a);i--) #define per(i,b) gnr(i,b-1,0) #define pb push_back #define eb emplace_back #define fi first #define se second #define bg begin() #define ed end() #define all(x) x.bg,x.ed #define si(x) int(x.size()) template<class t> using vc=vector<t>; template<class t> using vvc=vc<vc<t>>; typedef long long ll; using pii=pair<int,int>; using vi=vc<int>; using uint=unsigned; using ull=unsigned long long; using pil=pair<int,ll>; using pli=pair<ll,int>; using pll=pair<ll,ll>; using t3=tuple<int,int,int>; #define N_ 101000 vi E[N_]; int vis[N_], Q[N_], head,tail; void Add(int a){ if(vis[a])return; vis[a]=1; Q[++tail]=a; } int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S) { rng(i,0,N){ E[i].clear(); vis[i]=0; } rng(i,1,N-1){ E[F[i]].pb(i); } for(auto &t: S){ rng(j,1,si(t)-1){ E[t[j]].pb(t[j-1]); } } int pv = 0, res=0; while(pv < N-1){ res++; head=tail=0; Add(S[0][pv]); while(head<tail){ int x = Q[++head]; for(auto &y:E[x]){ Add(y); } } pv+=tail; } return res; }
#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...