Go: package main
import (
	"fmt"
	"bufio"
	"os"
	"bytes"
	"strconv"
	"strings"
)

func nextInt(scanner *bufio.Scanner) int {
	scanner.Scan()
	num , _ :=  strconv.Atoi(scanner.Text())
	return num
}


func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)

	N := nextInt(scanner)
	var A [][]int = make([][]int, N)
	for i:=0; i<N; i++ {
		A[i] = make([]int, N)
	}
	for i:=0; i<N; i++{
		idx := nextInt(scanner)
		cnt := nextInt(scanner)
		for j:=0; j<cnt; j++ {
			node := nextInt(scanner)
			A[idx-1][node-1] = 1
		}
	}
	var outBuffer bytes.Buffer
	for i:=0; i<N; i++ {
		outBuffer.WriteString(strings.TrimRight(fmt.Sprintf("%v",A[i])[1:], "]") + "\n")
	}
	fmt.Printf("%s", outBuffer.String())
}

C++: #include <iostream>

int main() {
    int node_num(0);
    std::cin >> node_num;

    /* Generate Empty Matrix */
    int** graph(nullptr);
    graph = new int*[node_num];
    for (int i(0); i < node_num; ++i) {
        graph[i] = new int[node_num];
        for(int j(0); j < node_num; ++j) {
            graph[i][j] = 0;
        }
    }

    /* Input and Modify Matrix*/
    for(int i(0); i < node_num; ++i) {
        int node_index(0);
        int node_degree(0);
        std::cin >> node_index >> node_degree;
        for(int j(0); j < node_degree; ++j) {
            int tmp(0);
            std::cin >> tmp;
            graph[node_index-1][tmp-1] = 1;
        }
    }

    /* Output 隣接行列 */
    for(int i(0); i < node_num; ++i) {
        for(int j(0); j < node_num; ++j) {
            if(j != 0) {
                std::cout << " ";
            }
            std::cout << graph[i][j];
        }
        std::cout << "\n";
    }

    for(int i(0); i < node_num; ++i ){
        delete graph[i];
    }

    delete graph;

    return 0;
}

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

int main(){
    int n;cin >> n;
    vector<vector<int>> vec(n,vector<int>(n));
    for(int i=0;i<n;i++){
        int j,k;cin >> j >> k;
        j--;
        for(int t = 0;t<k;t++){
            int s;cin >> s;s--;
            vec[j][s] = 1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            cout << vec[i][j];
            if(j!=n-1) cout << " ";
            else cout << endl;
        }
    }
}

C++: #include <iostream>
#include <stdio>

using namespace std;

int main(){
  int g[10010][10010]={};//要素を0で初期化
  int n,a,b,c;
  cin >> n;
  for (int i = 0; i < n; ++i)
   {
     cin >> a >> b ;
     for (int i = 0; i < b; ++i)
     {
       cin >> c;
       g[a-1][c-1]=1;/* code */
     }
   }
   for (int i = 0; i < n; ++i)
   {
     for (int j = 0; j < n; ++i)
     {
      if (j==n-1)
      {
        cout << g[i][j] << endl;
      }else{
        cout << g[i][j] <<" ";
      }
     }
   }

}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

bool A[110][110];

int main (){
	int n,a,b;
	char x;
	cin>>n;
	for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				A[i][j]=false;
		}
	}
	for(int i=1;i<=n;i++){
		cin>>a;
		while(1){
			cin>>b;
			if(A[b][a]==false) A[a][b]=true;
			x=getchar();
			if(x=='\n') break;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			if(j==n) cout<<A[i][j]<<" \n";
			else cout<<A[i][j]<<" ";
		}
	}
	return 0;
}

C++: #include <cstring>
#include <iostream>

int main() {
    int n;
    std::cin >> n;

    int ad_mat[n][n];
    memset(ad_mat, 0, sizeof(int) * n * n);

    int u, v, k;
    for (int i = 0; i < n; i++) {
        std::cin >> u >> k;
        for (int j = 0; j < k; j++) {
            std::cin >> v;
            ad_mat[u - 1][v - 1] = 1;
        }
    }
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n - 1; j++) {
            std::cout << ad_mat[i][j] << " ";
        }
        std::cout << ad_mat[i][n - 1] << std::endl;
    }
}

C++: //16D8103012G 三品海渡
#include<iostream>
#include<vector>
using namespace std;
int main() {
  int n;
  cin >> n;
  vector<vector<int>> ln(n, vector<int>(n+1, 0));
  vector<vector<int>> m(n,vector<int>(n,0));
  vector<int> rem(n, 0);
  for (int i = 0; i < n; i++)
    {
      cin >> ln[i][0];
      cin >> ln[i][1];
      for (int j = 2; j < ln[i][1]+2; j++)
	{
	  cin >> ln[i][j];
	}
    }
  for (int i = 0; i < n; i++)
    {

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

C++: #include <iostream>
#include <utility>
#include <string>
#include <algorithm>
#include <set>
#include <deque>
#include <vector>
#define MAX 10010
#define rep(i,p) for(int i=0;i<p;i++)
#define pb push_back
using namespace std;
int n,hoge,foo;
int graph[MAX][MAX] = {0};
int main(){
  cin >> n;
  rep(i,n) {
    cin >> hoge >> foo;
    rep(j,foo) {
      cin >> hoge;
      graph[i][hoge-1] = 1;
    }
  }
  rep(i,n) {
    rep(j,n) cout << graph[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 < k; j++) M[i][j] = 0;
	}
	for (int i = 0; i < n; i++) {
		cin >> u >> k;
		u--;
		for (int j = 0; i < n; i++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; k < n; j++) {
			if ( j ) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int n;
    cin >> n;
    int A[n][n] = {};
    rep(i, 0, n) {
        int u, k;
        cin >> u >> k;
        rep(j, 0, k) {
            int v;
            cin >> v;
            A[u - 1][v - 1] = 1;
        }
    }
    rep(i, 0, n) {
        rep(j, 0, n) {
            if (j == n - 1) cout << A[i][j] << endl;
            else cout << A[i][j] << " ";
        }
    }
    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; i < n; i++) {
			cin >> v;
			v--;
			M[u][v] = 1;
		}
	}
	for (int i = 0; i < n; i++) {
		for (int j = 0; k < n; j++) {
			if (j) cout << " ";
			cout << M[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

#define N 100

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

  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++: #include <bits/stdc++.h>
using namespace std;
const int N=100;
int main(void){
    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;
    }
}