Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n, err := nextInt(sc)
	if err != nil {
		panic(err)
	}
	matrix := make([][]int, n)
	for i := 0; i < n; i++ {
		matrix[i] = make([]int, n)
		id, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		vNum, err := nextInt(sc)
		if err != nil {
			panic(err)
		}
		for j := 0; j < vNum; j++ {
			v, err := nextInt(sc)
			if err != nil {
				panic(err)
			}
			matrix[id-1][v-1] = 1
		}
	}
	for i := 0; i < n; i++ {
		printRow(matrix[i])
	}
}

func printRow(row []int) {
	xs := make([]string, len(row))
	for i := 0; i < len(row); i++ {
		xs[i] = strconv.Itoa(row[i])
	}
	fmt.Println(strings.Join(xs, " "))
}

func nextInt(sc *bufio.Scanner) (int, error) {
	sc.Scan()
	return strconv.Atoi(sc.Text())
}

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

int main(){
    int M[100][100];
    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;
            //cout << M[i][j] << " ";
        }
        //cout << endl;
    }
    //cout << endl;
    
    for (int i=0; i<n; i++){
        cin >> u >> k; //uは頂点番号, kはuの出次数
        u--;
        for (int j=0; j<k; j++){
            cin >> v;//uに隣接する頂点番号
            v--;
            M[u][v]=1;
        }
        
    }
    
    for (int i=0; i<n; i++){
        for (int j=0; j<n; j++){
            if(j==n-1) cout << M[i][j];
            else cout << M[i][j] << " ";
        }
        cout << endl;
    }
}

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

int n;
int M[101][101];
int main() {
    cin >> n;

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

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

    return 0;
}

C++: #include <cstdio>
#include <cstdlib>

int main(int argc, char *argv[]) {
    int n;
    scanf("%d", &n);
    int adj_mat[n+1][n+1];

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

    // read
    for (int i = 1; i <= n; i++) {
        int node_id, adj_num;
        scanf("%d", &node_id);
        scanf("%d", &adj_num);
        for (int j = 1; j <= adj_num; j++) {
            int adj_id;
            scanf("%d", &adj_id);
            adj_mat[node_id][adj_id] = 1;
        }
    }

    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j != n) {
                fprintf(stdout, "%d ", adj_mat[i][j]);
            } else {
                fprintf(stdout, "%d\n", adj_mat[i][j]);
            }
        }
    }

    return 0;
}

C++: #include<iostream>

int main()
{
	int n, u, k, v;
	bool filled[100][100]{};

	std::cin >> n;
	for (int i = 0; i < n; ++i)
	{
		std::cin >> u >> k;
		u--;
		for (int j = 0; j < k; ++j)
		{
			std::cin >> v;
			filled[u][--v] = true;
		}
	}
	for (int i = 0; i < n; ++i)
	{
		for (int j = 0; j < n; ++j)
		{
			if (j)
				std::cout << " ";
			std::cout << static_cast<int>(filled[i][j]);
		}
		std::cout << std::endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main() {

    int n;
    cin >> n;
    int mat[100][100] = {};
    rep(i, n){
        int k, l;
        cin >> k >> l;
        rep(j, l){
            int v;
            cin >> v;
            mat[k-1][v-1] = 1;
        }
    }

    rep(i, n){
        rep(j, n){
            cout << mat[i][j];
            if(j == n-1){
                cout << "\n";
            }
            else{
                cout << ' ';
            }
        }
    }


    return 0;
}

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;
}