Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Split(bufio.ScanWords)
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	Adj := make([][]int, n)
	for i := range Adj {
		Adj[i] = make([]int, n)
	}
	for i := 0; i < n; i++ {
		scanner.Scan()
		u, _ := strconv.Atoi(scanner.Text())
		scanner.Scan()
		k, _ := strconv.Atoi(scanner.Text())
		if k == 0 {
			continue
		}
		for i := 0; i < k; i++ {
			scanner.Scan()
			v, _ := strconv.Atoi(scanner.Text())
			Adj[u-1][v-1] = 1
		}
	}
	for i := range Adj {
		for j := range Adj[i] {
			if j == n-1 {
				fmt.Printf("%d\n", Adj[i][j])
				continue
			}
			fmt.Printf("%d ", Adj[i][j])
		}
	}
}

C++: //16D8104001K 田中誠人 makoto0106 c++
#include<iostream>
#include<vector>
#include<algorithm>
int main()
{
  std::vector<int>num;
  int n,k,tmp,x,size;

  std::cin>>n;
  
  for(int i=0;i<n;i++){
    std::cin>>tmp>>k;
    num.push_back(k);
    for(int j=0;j<k;j++){
      std::cin>>tmp;
      num.push_back(tmp);
      //std::cout<<tmp<<" ";
    }
  }
  size=num.size();
  /*
  for(int i=0;i<size;i++){
    std::cout<<num[i]<<" ";
  }
  */
  x=0;
 
  while(x<size){
    if(num[x]==0){
      for(int i=0;i<n;i++){
	std::cout<<"0 ";
      }
      x++;
    }else{
      x++;
      for(int i=0;i<n;i++){
      
	if(i+1==num[x]){
	  std::cout<<"1 ";
	  x++;
	}else{
	  std::cout<<"0 ";
	}
      }
    }
    std::cout<<"\n";
  }
  
  
  return 0;
}

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

int main(){
  int n, u, k, x;
  int m[100][100]={0};

  cin >> n;

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

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

  return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef float fl;
typedef long long ll;
int n;
int a[101][101];

int main(){
    cin >> n;
    rep(i,n){
        int u, k; cin >> u >> k;
        rep(j,k){
            int l; cin >> l;
            a[i][l-1] = 1;
        }
    }
    
    rep(i,n){
        rep(j,n){
            if(j) cout << ' ';
            cout << a[i][j];
        }
        cout << endl;
    }
    return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
using namespace std;

const int MAX = 110;
int n;
int G[MAX][MAX];

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    memset(G, 0, sizeof(G));
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) {
        int p, k;
        scanf("%d %d", &p, &k);
        while (k--) {
            int ne = 0;
            scanf("%d", &ne);
            G[p][ne] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (j > 1) printf(" ");
            printf("%d", G[i][j]);
        }
        printf("\n");
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
using namespace std;
int  v[102][101], n;
int main() {
	int u, k, s;
	cin >> n;
	for (int i = 0; i <= n; i++) {
		for (int j = 0; j <= n; j++) {
			v[i][j] = 0;
		}
	}
	for (int i = 0; i < n; i++) {
		cin >> u;
		cin >> k;
		for (int j = 0; j < k; j++) {
			cin >> s;
			v[u][s] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			if (j) cout << " ";
			cout << v[i][j];
		}
		cout << endl;
	}	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int mat[n][n] = {};

    for(int i = 0; i < n; i++){
        int x, k, y;
        cin >> x >> k;
        while(k-- > 0){
            cin >> y;
            mat[x-1][y-1] = 1;
        }
    }

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

    return 0;
}

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

int main() {
	int n;
	cin>>n;
	int M[105][105];
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			M[i][j]=0;
		}
		
	}
	int h,p,e;
	for(int i=0;i<n;i++){
		cin>> h>>p;
		h--;
		for(int j=0;j<p;j++){
			cin>>e;
			e--;
			M[h][e]=1;
		}
	}
	for(int i=0;i<n;i++){
		for(int j=0;j<n;j++){
			if(j){
				printf(" ");
			}
			printf("%d",M[i][j]);
		}
		cout <<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void) {
	int n,u,k,v;
	cin >> n;
	int m[100][100];
	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;
	}
}

C++: #include<bits/stdc++.h>

#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define ll long long
#define bpm %1000000007

using namespace std;

ll powAns(ll,ll);

int main(){
    int n,u,k;
    int a;
    cin>>n;
    int vec[n][n];

    rep(i,n)rep(j,n)vec[i][j]=0;

    rep(i,n){
        cin>>u>>k;
        rep(j,k){
            cin>>a;
            vec[u-1][a-1]=1;
        }
    }
    rep(i,n){
        rep(j,n-1)cout<<vec[i][j]<<" ";
        cout<<vec[i][n-1]<<endl;
    }
}

ll powAns(ll m ,ll n){
    ll res=1;
    while(n>0){
        if(n & 1)res = res*m bpm;

        m=m*m bpm;
        n>>=1;
    }

    return res;
}

C++: #include<iostream>
#include<cstdio>
#include<algorithm>
#define MAX 110

using namespace std;

static const int N = 110;

int main(){
    int n;//頂点数
    cin >> n;

    int Adj[MAX];
    int M[N][N];
    
    int u;
    int k;
    int v;
    
    for(int i=1; i<=n; i++){
        M[i][i] = 0;
    }
    
    
    for(int j=1; j<=n; j++){
        cin >> u >>k;
        for(int a=1; a<=k; a++){
            cin >> v;
            Adj[v] = 1;
            
            if(Adj[v] != 0){
            M[u][v] = 1;
            }
        }
         
        
    }
    
    for(int j=1;j<=n; j++){
        for(int i=1; i<=n; i++){
            if(i != 1){
                cout << " ";
            }
            cout << M[j][i];
        }
        
        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;
            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;
    }

}

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

int main() {
  int n, k, v, u;
  cin >> n;
  vector<vector<int>> ADJ(n, vector<int>(n, 0));
  for (size_t i = 0; i < n; i++) {
    cin >> u >> k;
    for (size_t j = 0; j < k; j++) {
      cin >> v;
      ADJ[u - 1][v - 1] = 1;
    }
  }

  for (size_t i = 0; i < n; i++) {
    for (size_t j = 0; j < n; j++) {
      if (j == n - 1) {
        cout << ADJ[i][j] << endl;
      } else {
        cout << ADJ[i][j] << " ";
      }
    }
  }
}