Go: package main

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

func main() {
	var n int
	fmt.Scanf("%d", &n)

	adj := make([][]string, n)
	for i := 0; i < n; i++ {
		adj[i] = make([]string, n)
		for j := 0; j < n; j++ {
			adj[i][j] = "0"
		}
	}

	sc := bufio.NewScanner(os.Stdin)
	for i := 0; i < n; i++ {
		sc.Scan()
		adjList := strings.Split(sc.Text(), " ")
		outDegree, _ := strconv.Atoi(adjList[1])

		if outDegree > 0 {
			for k := 0; k < outDegree; k++ {
				j, _ := strconv.Atoi(adjList[k+2])
				adj[i][j-1] = "1"
			}
		}
	}

	for i := 0; i < len(adj); i++ {
		fmt.Println(strings.Join(adj[i], " "))
	}

}

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

using namespace std;

const int N_MAX = 100;

// グラフ
// 隣接リスト表現の有効グラフGの隣接行列を出力

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;

    int G[100][100] = { 0 };

    for (int i = 0; i< n; i++)
    {
        int u, k;
        cin >> u; // 頂点番号
        cin >> k; // 出次数
        for (int i = 0; i < k; i++)
        {
            int v;
            cin >> v;
            G[u-1][v-1] = 1;
        }
    }

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

C++: #include <iostream>
#include <string>
#include <unordered_map>
#include <stdio.h>
#include <list>
#include <queue>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; ++i)
typedef long long ll;

int main()
{
	int n;
	cin >> n;
	rep(i,n)
	{
		int hoge;cin>>hoge;
		int u; cin>>u;
		if(u==0)
		{
			rep(j,n)
			{
				if(j)cout<<" ";
				cout<<0;
			}
			cout<<endl;
			continue;
		}else
		{
		queue<int> v;
		rep(j,u){int a;cin>>a;v.push(a);}
		int itr=0;
		rep(j,n)
		{
			if(j)cout<<" ";
			if( (v.front()-1)==j)
			{
				cout<<1;
				v.pop();
			}
			else
			{
				cout<<0;
			}
		
			
			
		
		}
		}
		cout<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
  int n,u,k,v,**M;
  cin>>n;
  M=new int*[n];
  for(int i=0;i<n;i++)
    {
      M[i]=new int[n];
      for(int j=0;j<n;j++)
	M[i][j]=0;
    }
  int count=0;
  while(count<n)
    {
      count++;
      cin>>u>>k;
      for(int i=0;i<k;i++)
	{
	  cin>>v;
	  M[u-1][v-1]=1;
	}
    }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++)
      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] << " ";
        }
        cout << endl;
    }

    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int i;
  int a[150][150];
  int x,y;
  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      a[x][y]=0;
    }
  }

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

  }

  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      printf("%d ",a[x][y]);
    }printf("\n");
  }

  return 0;
}

C++: #include <iostream>

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 <iostream>
#include <vector>
#include <stack>
#include <queue>

using namespace std;

static const int N = 100;
int n, m[N][N];


int main()
{
	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) {
		int u, d; cin >> u >> d;
		for (int j = 0; j < d; ++j) {
			int v; cin >> v;
			m[u - 1][v - 1] = 1;
		}
	}

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

}

C++: #include<stdio.h>
#include<stdlib.h>
#pragma warning(disable:4996)

int main()
{
	int a = 0;
	scanf("%d", &a);
	int matrix[101][101] = { 0 };
	for (int i = 0; i < a; i++) {
		int row = 0;
		int column = 0;
		int count = 0;
		scanf("%d", &row);
		scanf("%d", &count);
		for (int j = 0; j < count; j++) {
			scanf("%d", &column);
			matrix[row-1][column - 1] = 1;
		}
	}
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < a; j++) {
			if (j < a - 1) {
				printf("%d ", matrix[i][j]);
			}
			else {
				printf("%d", matrix[i][j]);
			}
		}
		printf("\n");
	}
}

C++: #include <iostream>

using namespace std;
int dat[100][100];

int main(){
	int n, f, v, g;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>f>>v;
		for(int j=1;j<=v;j++){
			cin>>g;
			dat[f][g]=1;
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<n;j++){
			cout<<dat[i][j]<<" ";
		}
		cout<<dat[i][n]<<"\n";
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

using namespace std;

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

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
#define maxn 10005
int n,u,k;
int g[maxn][maxn];
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
        int v;
        scanf("%d%d",&u,&k);
        for(int j=1;j<=k;j++)
        {
            scanf("%d",&v);
            g[u][v]=1;
        }
    }

    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<n;j++)
        {
            printf("%d ",g[i][j]);
        }
        printf("%d\n",g[i][n]);
    }

    return 0;
}

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

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

const int MAX_N = 100;
int G[MAX_N][MAX_N];

int main() {
    REP(i,MAX_N) REP(j,MAX_N) G[i][j] = 0;
    int N; cin >> N;
    for(int i = 0; i < N; i++) {
        int u, k; cin >> u >> k; u--;
        while(k--) {
            int v; cin >> v; v--;
            G[u][v] = 1;
        }
    }
    for(int i = 0; i < N; i++)
        for(int j = 0; j < N; j++)
            cout << G[i][j] << " \n"[j == N - 1];
}