delete pics to save space
This commit is contained in:
25
history_source/信息学奥赛一本通/3.4.4.1.cpp
Normal file
25
history_source/信息学奥赛一本通/3.4.4.1.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include<cstdio>
|
||||
#define maxn 200
|
||||
int fa[maxn+1],n,t,i,j,k,ans;
|
||||
bool w[maxn+1][maxn+1];
|
||||
int main()
|
||||
{
|
||||
freopen("cdrom.in","r",stdin);
|
||||
freopen("cdrom.out","w",stdout);
|
||||
scanf("%d",&n);
|
||||
for(i=1;i<=n;i++)
|
||||
{
|
||||
while(scanf("%d",&t),t>0) w[i][t]=1;
|
||||
fa[i]=i;
|
||||
}
|
||||
for(k=1;k<=n;k++)
|
||||
for(i=1;i<=n;i++)
|
||||
for(j=1;j<=n;j++)
|
||||
w[i][j]=w[i][j]||(w[i][k]&&w[k][j]);
|
||||
for(i=1;i<=n;i++)
|
||||
for(j=1;j<=n;j++)
|
||||
if(w[i][j]) fa[j]=fa[i];
|
||||
for(i=1;i<=n;i++) if(fa[i]==i) ans++;
|
||||
printf("%d\n",ans);
|
||||
return 0;
|
||||
}
|
Reference in New Issue
Block a user