Submission #1000778

#TimeUsernameProblemLanguageResultExecution timeMemory
1000778imarnSeptember (APIO24_september)C++17
100 / 100
276 ms10736 KiB
#include<bits/stdc++.h> #pragma GCC optimize("O3") #pragma GCC target("avx2") #define ll long long #define pii pair<int,int> #define pll pair<ll,ll> #define plx pair<ll,int> #define f first #define s second #define pb push_back #define all(x) x.begin(),x.end() #define vi vector<int> #define vl vector<ll> #define vvi vector<vi> using namespace std; const int mxn=1e5+5; vector<int>g[mxn]; bool vis[mxn]{0}; int cnt[6]{0}; void dfs(int u){ vis[u]=1; for(int i=0;i<5;i++)cnt[i]++; for(auto v:g[u]){ if(!vis[v])dfs(v); } } int solve(int N, int M, std::vector<int> F, std::vector<std::vector<int>> S){ for(int i=1;i<N;i++)g[F[i]].pb(i); int ans=0; for(int i=0;i<N-1;i++){ for(int j=0;j<M;j++){ if(!vis[S[j][i]])dfs(S[j][i]); if(vis[S[j][i]])cnt[j]--; }bool ch=0; for(int j=0;j<M;j++)if(cnt[j]!=0)ch=1; if(!ch)ans++; }memset(vis,0,sizeof vis);memset(cnt,0,sizeof cnt); for(int i=0;i<mxn;i++)g[i].clear(); return ans; }
#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...