Submission #51588

#TimeUsernameProblemLanguageResultExecution timeMemory
51588thiago4532Bosses (BOI16_bosses)C++17
0 / 100
2 ms376 KiB
#include <bits/stdc++.h> #define gc getchar #define rep(i, a, b) for(int i=a;i<=b;i++) #define rep2(i, a, b) for(int i=a;i>=b;--i) #define wipe(a, b) memset(a, b, sizeof a); #define pb push_back using namespace std; const int maxn = 20; vector<int> bosses[maxn], employ[maxn]; inline int scan(){ int n=0, x=gc(), s=1; for(;x<'0'||x>'9';x=gc()) if(x=='-') s=-1; for(;x>='0'&&x<='9';x=gc()) n = 10*n + x - '0'; return n*s; } bool mark[maxn]; int dfs(int u){ mark[u] = true; int resp = 1; for(auto v : employ[u]) if(!mark[v]) resp += dfs(v); return resp; } int main(){ ios::sync_with_stdio(false), cin.tie(0); int n = scan(); rep(i, 1, n){ int k = scan(); rep(j, 1, k){ int x = scan(); bosses[i].push_back(x); employ[x].push_back(i); } } int maior=-0x3f3f3f3f, l=0; rep(u, 1, n){ if(maior < (int)employ[u].size()){ maior = employ[u].size(); l = u; } } cout << dfs(l) << "\n"; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...