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<algorithm>
using namespace std;

int main(){
  
  int n, u, k, v;
  bool a[110][110] = {}; //adjacency matrix

  //input
  cin >> n;
  for(int i = 0;i < n;i++){
    cin >> u >> k;
    for(int j = 0;j < k;j++){
      cin >> v;
      a[u][v] = true;
    }
  }

  //output
  for(int i = 1;i <= n;i++){
    for(int j = 1;j <= n;j++){
      cout << (j - 1?" ":"");
      cout << a[i][j];
    }
    cout << endl;
  }
  
  return 0;
}

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

using namespace std;

//4
//1 2 2 4
//2 1 4
//3 0
//4 1 3

//0 1 0 1
//0 0 0 1
//0 0 0 0
//0 0 1 0

int main() {

	int n;
	scanf("%d", &n);

	int G[n][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;
		scanf("%d %d", &u, &k);
		for (int j = 0; j < k; ++j) {
			int v;
			scanf("%d", &v);
			G[i][v - 1] = 1;
		}
	}

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

	return 0;

}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<queue>
#include<stdio.h>
#include<stdlib.h>
#include<map>
#ifndef NULL
#define NULL 0
#endif
using namespace std;

int mp[110][110];
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		int a, b;
		cin >> a >> b;
		for (int j = 0; j < b; j++) {
			int c;
			cin >> c;
			mp[a][c] = 1;
		}
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j < n; j++)
			cout << mp[i][j] << ' ';
		cout << mp[i][n] << endl;
	}
	return 0;
}

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

C++: //
// Created by tattsun on 2017/02/11.
//

#include <iostream>
#include <vector>
using namespace std;

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

    int u, k, p;
    for(int i=0; i<n; i++) {
        cin >> u >> k;

        vector<int> dest;
        for(int j=0; j<k; j++) {
            cin >> p;
            dest.push_back(p);
        }

        auto it = dest.begin();
        for(int j=0; j<n; j++) {
            if(j != 0) cout << " ";
            if(it != dest.end() && j == *it-1) {
                cout << "1";
                it++;
            } else {
                cout << "0";
            }
        }
        cout << endl;
    }
}

C++: #include <stdio.h>
#define N 100

int main(void){
  int i,j,n,u,k,w;
  int v[N][N];
  scanf("%d",&n);

  for(i =0; i<n ;i++){
    for (j=0 ; j<n; j++){
      v[i][j]=0;
    }
  }

  for(i=0 ;i<n;i++){
    scanf("%d%d",&u,&k);
    for (j=0;j<n;j++){
      scanf("%d",&w);
      v[u-1][w-1]=1;
    }
  }

  for (i =0 ; i <n ;i++){
    for(j=0 ; j<n ; j++){
      if(j) printf(" ");
      printf("%d",v[i][j]);
    }
    printf("\n");
  }
  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int n, m, u, v, adj[105][105];
int main() {
    cin >> n;
    for (int i=0; i<n; i++) {
        cin >> u >> m;
        for (int j=0; j<m; j++) {
            cin >> v;
            adj[u][v]=1;
        }
    }
    
    for (int i=1; i<=n; i++) {
        for (int j=1; j<=n; j++) {
            cout << adj[i][j];
            if (j!=n) cout << " "; 
        }
        cout << "\n";
    }
}

C++: //
//  main.cpp
//  graph
//
//  Created by ???????????? on 2017/10/22.
//  Copyright ?? 2017 ????????????. All rights reserved.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int main(int argc, const char * argv[]) {
    int n, i, j, id, num, node;
    scanf("%d", &n);
    int A[n][n];
    
    //initialize with 0
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            A[i][j] = 0;
        }
    }
    
    for (i = 0; i < n; i++){
        scanf("%d", &id);
        scanf("%d", &num);
        for(j = 0; j < num; j++){
            scanf("%d", &node);
            A[id-1][node-1] = 1;
        }
    }
    
    for(i = 0; i < n; i++){
        for(j = 0; j < n; j++){
            if(j) cout << " ";
            cout<<A[i][j];
        }
        cout<<endl;
    }
    
//    std::cout << "Hello, World!\n";
    return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>

#include <cstdio>

using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define print_array(ary, size) cout << ary[0]; rep1(i, 1, size - 1) cout << ' ' << ary[i]; cout << endl;
typedef long long ll;
typedef unsigned long long ull;

int a[101][101] = { 0 };

int main()
{
	int n;
	int u, k, v;

	cin >> n;
	rep(i, n) {
		cin >> u >> k;
		rep(j, k) {
			cin >> v;
			a[u][v] = 1;
		}
	}

	repc(i, 1, n) {
		cout << a[i][1];
		repc(j, 2, n) cout << ' ' << a[i][j];
		cout << endl;
	}

	return 0;
}

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

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

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

using namespace std;

void to_adjacent_matrix(vector<vector<int> >& adjacent_list, vector<vector<int> >& adjacent_matrix);

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

    vector<vector<int> > vertex(n, vector<int>(n, -1));
    for (int i = 0; i < n; ++i) {
        int u, k;
        cin >> u >> k;

        for (int j = 0; j < k; ++j)
            cin >> vertex[i][j];
    }

    vector<vector<int> > adjacent(n, vector<int>(n, 0));
    to_adjacent_matrix(vertex, adjacent);

    for (int i = 0; i < n; ++i) {
        cout << adjacent[i][0];
        for (int j = 1; j < n; ++j)
            cout << ' ' << adjacent[i][j];
        cout << '\n';
    }
}

void to_adjacent_matrix(vector<vector<int> >& adjacent_list, vector<vector<int> >& adjacent_matrix)
{
    int n = adjacent_list.size();

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n && adjacent_list[i][j] != -1; ++j) {
            int adjacent = adjacent_list[i][j] - 1;
            if (adjacent < 0 || adjacent > n)
                continue;

            adjacent_matrix[i][adjacent] = 1;
        }
    }
}