#include<iostream>
using namespace std;
#define MAX 100
int M;
int a[MAX][MAX];
int phao[MAX];
bool visit[MAX];
void DFS(int v)
{
visit[v]= true;
for(int i = 0; i< 100; i++)
if(visit[i]=false && a[v][i] == 1)
{
DFS(i);
}
}
void reset()
{
for(int i = 0; i<M; i++)
for(int j = 0; j < M; j++)
a[i][j] = 0;
}
int main()
{
int current, nextCount, other;
freopen("input.txt","r",stdin);
cin >> M;
reset();
for(int i = 1; i<=M; i++)
{
cin >> current;
cin >> phao[current];
cin >> nextCount;
for(int j = 1; j<=nextCount;j++)
{
cin >> other;
a[current][other] = 1;
a[other][current] = 1;
}
}
}
Be the first to comment
You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.