제출 #1087538

#제출 시각아이디문제언어결과실행 시간메모리
1087538veehj9월 (APIO24_september)C++17
0 / 100
1 ms348 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) 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]); if(nchild[s[j][i]]==0) pop(s[j][i]); else tagged.insert(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...