This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |