Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

C++: #include<iostream>
using namespace std;

int main(){
    int n; cin >> n;
    int A[n][n];
    
    //初期化
    for (int i=0;i<n;i++){
        for(int j =0;j<n;j++){
            A[i][j] =0;
        }
    }
    
    for(int i = 0;i<n;i++){
        int num,ver;
        cin >> num >> ver;
        for (int j = 0;j< ver;j++){
            int u; cin >> u;
            A[num-1][u-1] =1;
        }
    }
     for (int i=0;i<n;i++){
        for(int j =0;j<n;j++){
            cout << A[i][j]  ;
            if (j != n-1) cout << " ";
            
        }cout << endl;
    }
}

C++: #include<iostream>
#include<vector>
#include<cstdio>
using namespace std;
int judge(int i, int n, int variable, vector< vector<int> > &v)
{
	for (int j = 0; j<v[variable].size(); ++j) {
		if (i == v[variable][j]) {
			return 1;
			break;
		}
	}
	return 0;
}
int main()
{
	int n, u, k, vv;
	cin >> n;
	vector< vector<int> > v(n), a(n, vector<int>(n));
	for (int variable = 0; variable<n; ++variable) {
		cin >> u >> k;
		for (int i = 0; i<k; ++i) {
			cin >> vv;
			v[variable].push_back(vv);
		}
	}
	for (int variable = 0; variable<n; ++variable)
		for (int i = 1; i <= n; ++i)
			a[variable][i - 1] = judge(i, n, variable, v);
	for (int variable = 0; variable<n; ++variable)
		for (int i = 0; i<n; ++i)
			printf("%d%c", a[variable][i], i == n - 1 ? '\n' : ' ');
}

C++: #include <stdio.h>
#include <string.h>

int main(){
  int Adj[101][101],n,v,i,j,u,k;
  memset(Adj, 0, 101*101*sizeof(int));
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    scanf("%d%d",&u,&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      Adj[u][v]=1;
    }
  }
  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      if(j!=1)printf(" ");
      printf("%d",Adj[i][j]);
    }
    printf("\n");
  }
  
  return 0;
}

C++: #include<iostream>
using namespace std;
static const int N=100;

main(){
int M[N][N];
int n,u,k,v;

cin >> n;

for(int i=0;i<n;i++){
for(int j=0;j<n;j++)M[i][j]=0;
}

for(int i=0;i<n;i++){
cin >> u >> k;
u--;
for(int j=0;j<k;j++){
cin >> v;
v--;
M[u][v]=1;
}
}

for(int i=0;i<n;i++){
for(int j=0;j<n;j++){
if(j)cout << " ";
cout << M[i][j];
}
cout << endl;
}

return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

int main(){
	int g[100][100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			g[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		int u, k, v;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			g[u - 1][v - 1] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (j > 0) {
				cout << " ";
			}
			cout << g[i][j];
		}
		cout << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main() {
	int M[N][N];
	int n, u, k, v;

	cin >> n;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) M[i][j] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; j < k; j++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if ( j ) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
static const int N=100;

int main(){
  int m[N][N],n,u,k,v,i,j;

  cin >> n;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++) m[i][j]=0;
  }
  for(i=0;i<n;i++){
    cin >> u >> k;
    u--;
    for(j=0;j<k;j++){
      cin >> v;
      v--;
      m[u][v]=1;
    }
  }

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j) cout << " ";
      cout << m[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: //
#if 0

#endif // 0
#include<iostream>
#define MAX 100
using namespace std;
int matri[MAX][MAX];

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<n;j++)
            matri[i][j]=0;
    for(int i=0;i<n;i++)
    {
        int u,k;
        cin>>u>>k;
        for(int j=0;j<k;j++)
        {
            int m;
            cin>>m;
            matri[u-1][m-1]=1;
        }
    }
    for(int i=0;i<n;i++)
    {
        int j;
        for(j=0;j<n-1;j++)
            cout<<matri[i][j]<<" ";
        cout<<matri[i][j]<<endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
	int n,m,l,i,j,p;
	cin >> n;
	int f[100][100];
	for ( i = 0; i < n; i++){
		cin >> m;
		cin >> p;
		for ( j = 0; j < p; j++){
			cin >> l;
			f[m-1][l-1] = 1;
		}
	}
	for ( i = 0; i < n; i++){
		for ( j = 0; j < n-1; j++){
			cout << f[i][j] << " ";
		}
		cout << f[i][n-1] << endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(int i=0;i<n;++i)

const int MAX_N = 100;

int main() {
  int n, u, k, v, G[MAX_N][MAX_N] = {0};
  cin >> n;
  REP(i, n) {
    cin >> u >> k;
    REP(j, k) {
      cin >> v;
      G[u - 1][v - 1] = 1;
    }
  }
  REP(i, n) {
    REP(j, n) {
    if(j) cout << ' ';
    cout << G[i][j];
    }
    cout << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#define N 200

int main(){
  int M[N][N];
  int n,u,k,v;

  scanf("%d",&n);

  for(int i=0;i<n;i++){
    for(int j;j<n;j++)
      M[i][j]=0;
    
  }
  for(int i=0;i<n;i++){
    scanf("%d%d",&u,&k);
    u--;
    for(int j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      M[u][v]=1;
      
    }
      
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(j)printf(" ");
      printf("%d",M[i][j]);}
    printf("\n");


    }

  return 0;
  }

C++: #include <iostream>
using namespace std;

int main()
{
	//ios::sync_with_stdio(false);
	//cin.tie(0);

	static int M[101][101];
	int n;
	cin >> n;

	int u, k, v;
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			cin >> v;
			M[u][v] = 1;
		}	
	}

	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j != 1) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

using Adjacents = vector<int>;
using Vertexes = vector<Adjacents>;

int main(void) {

    int N;
    scanf("%d", &N);

    Vertexes vs;
    vs.resize(N);
    for (int i = 0, id, num; i < N; ++i) {
        scanf("%d %d", &id, &num);
        for (int j = 0, vert; j < num; ++j) {
            scanf("%d", &vert);
            vs[id-1].push_back(vert);
        }
    }

    int **matrix = new int*[N];
    for (int i = 0; i < N; ++i) {
        matrix[i] = new int[N];
        memset(matrix[i], 0, sizeof(int)*N);
        for (int j = 0; j < vs[i].size(); ++j) {
            matrix[i][vs[i][j] - 1] = 1;
        }
    }

    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < N; ++j) {
            printf("%2d", matrix[i][j]);
        }
        delete[] matrix[i];
        printf("\n");
    }
    delete[] matrix;

    return 0;
}

C++: #include <iostream>
using namespace std;

int main(){
	int a[102][102] = {};
	int n,u,k,b;
	cin >> n;
	for(int i = 1;i <= n;i++){
		cin >> u >> k;
		for(int j = 0;j < k;j++){
			cin >> b;
			a[i][b] = 1;
		}
	}

	for(int i = 1;i <= n;i++){
		for(int j = 1;j <= n;j++){
			if(j != n){
				cout << a[i][j] << " ";
			}
			else cout << a[i][j] << endl;
		}
	}

	return 0;
}