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++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

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

struct Node {
  int num = 0,
      deg = 0;
  vi v;
  Node(int num = 0): num(num) {}
};

int main() {
  int n;
  cin >> n;
  
  vector<Node> g(n);
  rep(i, n) {
    int num;
    cin >> num;
    auto nd = new Node(num);
    cin >> nd->deg;
    rep(j, nd->deg) {
      int v;
      cin >> v;
      nd->v.push_back(v);
    } 

    g[i] = *nd;
  }
  
  rep(i, n) {
    auto nd = g[i];
    int r = 0;
    rep(j, n) {
      int p;
      if (nd.v.size() && r < nd.v.size() && j + 1 == nd.v[r]) {
        p = 1;
        r++;
      } else p = 0;
      printf(j == n - 1 ? "%d\n" : "%d ", p);
    }
  }
}

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

int main(){
  int n,u,k;
  int ad;
  int arr[200][200] = {0};
  scanf("%d",&n);
  for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int i=0;i<k;i++){
      cin >> ad;
      arr[u][ad] = 1;
    }
  }

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

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

int main() {
    int n, idx, g_num, a;
    int G[MAX+1][MAX+1];

    cin >> n;
    for(int i=0; i<n; i++) {
        cin >> idx >> g_num;
        for(int j=0; j<=n; j++) {
            G[idx][j] = 0;
        }
        for(int j=0; j<g_num; j++) {
            cin >> a;
            G[idx][a] = 1;
        }   
    }

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

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>

using namespace std;
    
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <limits>
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<vector<int>> vec(n);
    vector<int> SIZE;
    for(int i=0;i<n;i++){
        int x;
        cin >> x;
        int num;
        cin >> num;
        SIZE.push_back(num);
        for(int j = 0;j< num;j++){
            int y;
            cin >> y;
            vec[x-1].push_back(y-1) ;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            bool hantei=0;
            for(int k=0;k<SIZE[i];k++){
                
                if(vec[i][k]==j) {
                    if(j!=n){
                        cout << 1 <<" "; hantei=1;
                    }else{
                        cout << 1 ;
                    }    
                }
            }
            if(hantei==0){ 
                if(j!=n){
                    cout <<0<<" ";
                }else{
                    cout << 0;
                }
                
            };
        }cout << endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(){
    int n;
    cin>>n;
    int u,k,v;
    int A[100][100]={{}};
    for(int i=0;i<n;i++){
         cin>>u>>k;
         if(k!=0){
             for(int i=0;i<k;i++){
                cin>>v;
                A[u-1][v-1]=1;
             }
         }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j==0){
            cout<< A[i][j];
            }
            else{
                cout<<" "<<A[i][j];
            }
        }
        cout<<endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


int n;
int g[110][110];

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

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

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <cstdlib>
#include <string>
#include <iostream>
#include <climits>

using namespace std;


int main() {
	int n;
	int u, v;
	int Adj[101][101];
	int deg;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			Adj[i][j] = 0;
		}
	}
	for (int i = 1; i <= n; i++) {
		cin >> u;
		cin >> deg;
		for (int j = 1; j <= deg; j++) {
			cin >> v;
			Adj[u][v] = 1;
		}
	}
	for(int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			printf("%d", Adj[i][j]);
			if (j != n) {
				printf(" ");
			}
		}
		printf("\n");
	}
}

C++: #include<stdio.h>
#include<algorithm>
#include<string.h>
using namespace std;
#define INFTY 2000000001
#define MAX 101

int n = 0;
int adl[MAX][MAX], deg[MAX];
int adm[MAX][MAX];

int main() {
  scanf("%d", &n);
  for ( int i = 0; i < n; i++ ) {
    for ( int j = 0; j < n; j++ ) {
      adm[i][j] = 0;
    }
  }
  for ( int i = 0; i < n; i++ ) {
    int num;
    scanf("%d", &num);
    num--;
    scanf("%d", &deg[num]);
    for ( int j = 0; j < deg[num]; j++) {
      scanf("%d", &adl[num][j]);
      adl[num][j]--;
      adm[num][adl[num][j]] = 1;
    }
  }

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

  return 0;
}

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

//隣接行列
int d[101][101];

int main(){
  
  int u,k,v,n;
  cin >> n;
  //入力
  for(int i = 0; i < n; i++){
    cin >> u >> k;
    for(int j = 0; j < k; j++){
      cin >> v;
      d[u][v] = 1;//隣接しているところを1にする
    }
  }
  //出力
  for(int i = 1; i <= n; i++){
    for(int j = 1; j <= n; j++){
      //最後に空白が入らないようにする
      if(j == n){
	cout << d[i][j];
      }else{
	cout << d[i][j] << " ";
      }
    }
    cout << endl;
  }
  return 0;
}

C++: int main(){ //??°???????????£??\??????????????£??\?????????????????????????????°??????
    
    int n,k,v,w;
    
    cin >> n; //??°????????????????????\???
    
    Matrix M(n,Array(n,0)); //??£??\??????????????????
    
    for (int i=0; i<n; i++) { //??????????¬???°?????????????????\??? ???????????\??????????????£??\??????????????£??\?????????????´?
        cin >> w >> k;
        for (int j=0; j<k; j++) {
            cin >> v;
            M[w-1][v-1] = 1; //?????????
        }
    }
    
    for (int i=0; i<n; i++) { //????????¢?????§??????
        for (int j=0; j<n; j++) {
            cout << M[i][j];
            if (j!=n-1) {
                cout << " ";
            }
        }
        cout << endl;
    }
    
    return 0;
}