# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
77033 | farukkastamonuda | Bosses (BOI16_bosses) | C++14 | 3 ms | 1288 KiB |
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 li 10005
#define lo long long
using namespace std ;
lo int n,x,y,vis[li],sub[li],par[li],vis2[li];
vector<lo int> v[li],vec[li];
queue<int> q;
void dfs(int node,int ata){
if(vis2[node]==1) return ;
vis2[node]=1;
sub[node]=1;
for(int i=0;i<(int)v[node].size();i++){
int go=v[node][i];
//if(go==par[node]) continue;
if(vis2[go]==0){
dfs(go,node);
sub[node]+=sub[go];
}
}
sub[node]+=1;
}
int main(){
scanf("%lld",&n);
for(int i=1;i<=n;i++){
scanf("%lld",&x);
for(int j=1;j<=x;j++){
scanf("%lld",&y);
v[y].push_back(i);
}
}
lo int cev=0;
for(int i=1;i<=n;i++){
q.push(i);
while(!q.empty()){
// printf("*");
int temp=q.front();
q.pop();
if(vis[temp]==1) continue;
vis[temp]=1;
for(int i=0;i<(int)v[temp].size();i++){
int go=v[temp][i];
if(vis[go]==0 && par[go]==0){
vec[temp].push_back(go);
vec[go].push_back(temp);
par[go]=temp;
q.push(go);
}
}
}
//for(int j=1;j<=n;j++) printf("%d ",par[j]);
// return 0;
dfs(i,-1);
cev=max(cev,sub[i]);
for(int j=1;j<=n;j++) vec[j].clear();
memset(vis,0,sizeof(vis));
memset(vis2,0,sizeof(vis2));
}
printf("%lld\n",cev);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |