Submission #1087540

#TimeUsernameProblemLanguageResultExecution timeMemory
1087540veehjSeptember (APIO24_september)C++17
100 / 100
148 ms16580 KiB
// #include "september.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; typedef long double ld; #define F first #define S second #define pb push_back #define sz(a) (ll) a.size() #define all(x) (x).begin(), (x).end() vector<int> vist, nchild, pa; set<int> call, tagged; vector<vector<int>> child; void pop(int nw){ if(nchild[nw]!=0 || nw==0 || !tagged.count(nw)) return; tagged.erase(nw); nchild[pa[nw]]--; pop(pa[nw]); } int solve(int n, int m, std::vector<int> f, std::vector<std::vector<int>> s) { int ans=0; pa=f; vist.assign(n, 0); nchild.assign(n, 0); call={}; tagged={}; child.assign(n, vector<int>(0)); for(int i=1; i<n; i++){ child[pa[i]].pb(i); nchild[pa[i]]++; } for(int i=0; i<n-1; i++){ for(int j=0; j<m; j++){ vist[s[j][i]]++; if(vist[s[j][i]]!=m){ call.insert(s[j][i]); continue; } call.erase(s[j][i]); tagged.insert(s[j][i]); if(nchild[s[j][i]]==0) pop(s[j][i]); } ans+=(tagged.empty() && call.empty()); } 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...