Răspuns:
#include<bits/stdc++.h>
using namespace std;
ifstream in("retea.in");
ofstream out("retea.out");
int a[101][101],n,m,x,y;
inline void dfs(int x,int nrc,int v[],int y)
{
v[x]=nrc;
for(int i=1;i<=n;i++)
if(!v[i] && a[x][i] && x!=y && i!=y)
dfs(i,nrc,v,y);
}
inline void verif(int x)
{
register int v[101],nrc=0;
memset(v,0,sizeof(v));
for(int i=1;i<=n;i++)
if(!v[i] && i!=x)
dfs(i,++nrc,v,x);
nrc==1?out<<0<<" ":out<<1<<" ";
}
inline void citire()
{
in>>n>>m;
while(in>>x>>y)
a[x][y]=a[y][x]=1;
for(int i=1;i<=n;i++)
verif(i);
}
int main()
{
citire();
return 0;
}
Explicație: