Go: package main

import "fmt"

func main() {
	var N int
	fmt.Scan(&N)
	graph := make([][]int, N)
	for i := range graph {
		graph[i] = make([]int, N)
		var u, k int
		fmt.Scan(&u, &k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			v--
			graph[i][v] = 1
		}
	}
	for i := 0; i < N; i++ {
		for j := 0; j < N; j++ {
			if j > 0 {
				fmt.Print(" ")
			}
			fmt.Print(graph[i][j])
		}
		fmt.Println()
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
int main(){
  int a[101][101]={};
  int n,u,k,v;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v;
      a[u][v]=1;
    }
  }
  for(int i=1;i<=n;i++){
    for(int j=1;j<n;j++)
      cout<<a[i][j]<<' ';
    cout<<a[i][n]<<endl;
  }
  return 0;
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > graph(n, vector<int>(n, 0));
    rep(i, n)
    {
        int u, k;
        cin >> u >> k;
        u--;
        rep(i, k)
        {
            int v;
            cin >> v;
            v--;
            graph[u][v]++;
        }
    }

    rep(i, n)
    {
        rep(j, n)
        {
            if (j == n - 1)
            {
                cout << graph[i][j];
            }
            else
            {
                cout << graph[i][j] << ' ';
            }
        }
        cout << endl;
    }

    return 0;
}

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

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

using namespace std;

// graph
// adjacent list
vector<vector<int>> G; 
// adjacent matrix
const int MAX_N = 100;
int GM[MAX_N][MAX_N];

int main(){
    // input 
    int n; cin >> n;
    G.resize(n);
    rep(i, n){
        int from, edgeNum, to;
        cin >> from >> edgeNum;
        G[from-1].resize(edgeNum);
        rep(j, edgeNum){
            cin >> G[from-1][j];
        }
    }

    // output adjacent matrix
    rep(u, n){
        rep(i, G[u].size()){
            GM[u][G[u][i]-1] = 1; 
        }
    }
    rep(i, n)
        rep(j, n)
            cout << GM[i][j] << (j<n-1? " ": "\n");
}

C++: //
// Created by 李青坪 on 2018/10/31.
//

#include <cstdio>
#include <algorithm>

#define MAXN 101
using namespace std;

int graph[MAXN][MAXN];

void init(){
    for (int i = 0; i < MAXN; ++i) {
        fill(graph[i], graph[i]+MAXN, 0);
    }
}

int main(){
    int n;
    scanf("%d", &n);
    int v, dgr;
    for (int i = 0; i < n; ++i) {
        scanf("%d %d", &v, &dgr);
        int node;
        for (int j = 0; j < dgr; ++j) {
            scanf("%d", &node);
            graph[v][node] = 1;
        }
    }
    for (int k = 1; k <= n; ++k) {
        for (int i = 1; i <= n; ++i) {
            if (i-1) printf(" ");
            printf("%d", graph[k][i]);
        }
        printf("\n");
    }
}
/*
4
1 2 2 4
2 1 4
3 0
4 1 3

 */

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

int n, u, k, uk;
int G[101][101] = {0};

int main() {
	cin >> n;
	for (int i=0; i<n; ++i) {
		cin >> u >> k;
		while (k --) {
			cin >> uk;
			G[u][uk] = 1;
		}
	}
	for (int i=1; i<=n; ++i) {
		for (int j=1; j<=n; ++j) {
			cout << (j==1 ? "" : " ") << G[i][j];
		}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>

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

int main() {
  int n;
  std::cin >> n;
  int a[n][n];
  rep(i, n) rep(j, n) a[i][j] = 0;

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

  rep(i, n) {
    rep(j, n) {
      if (j) std::cout << ' ';
      std::cout << a[i][j];
    }
    std::cout << '\n';
  }
  return 0;
}

C++: #include <cstdint>
#include <vector>

using namespace std;
#define GRAPH_SIZE 100

static vector<uint32_t> graph[GRAPH_SIZE];

void graph_to_matrix(vector<uint32_t> graph[], uint32_t matrix[][GRAPH_SIZE])
{
  for(uint32_t i = 0; i < GRAPH_SIZE; i++){
    for(uint32_t j = 0; j < GRAPH_SIZE; j++){
      matrix[i][j] = 0;
    }
  }

  for(uint32_t i = 0; i < GRAPH_SIZE; i ++){
    for(uint32_t j = 0; j < graph[i].size(); j++){
      uint32_t val = graph[i][j];
      matrix[i][val] = 1;
    }
  }
}

#include <iostream>

static uint32_t matrix[GRAPH_SIZE][GRAPH_SIZE];

int32_t main(void)
{
  uint32_t num;
  cin >> num;
  for(uint32_t i = 0; i < num; i++){
    uint32_t index, len;
    cin >> index >> len;
    for(uint32_t j = 0; j < len; j++){
      uint32_t val;
      cin >> val;
      graph[index - 1].push_back(val - 1);
    }
  }
  graph_to_matrix(graph, matrix);

  for(uint32_t i = 0; i < num; i++){
    for(uint32_t j = 0; j < num; j++){
      if(j != 0) cout << " ";
      cout << matrix[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

int main(void){
  int m, a[100][100];
  int b[100][100];

  cin >> m;

  for(int i=0; i<m; i++){
    cin >> a[i][0];
    cin >> a[i][1];

    for(int j=2; j<a[i][1]+2; j++){
      cin >> a[i][j];
      b[i][ a[i][j]-1 ] = 1;
    }
  }

  for(int i=0; i<m; i++){
    for(int j=0; j<m; j++){
      cout << b[i][j] << " ";
    }
    cout << "\n";
  }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#define b 100
int main(){
    int n,hang,lie,cisu;
    scanf("%d",&n);
    int mtx[b][b]={0};
    
    for(int i=0;i<n;i++){
        scanf("%d%d",&hang,&cisu);
        for(int j=0;j<cisu;j++){
            scanf("%d",&lie);
            mtx[hang-1][lie-1]=1;
        }
    }
    
    for(int i=0;i<n;i++){
        for (int j=0; j<n-1; j++) {
            printf("%d ",mtx[i][j]);
            }
        printf("%d",mtx[i][n-1]);
        printf("\n");
    }
}

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

int main(){
  int a,b,c,d,g[101][101];
  cin>>a;
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      g[i][j]=0;
    }
  }
  for(int i=0;i<a;i++){
    cin>>b>>c;
    for(int j=0;j<c;j++){
      cin>>d;
      g[b][d]=1;
    }
  }
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      cout<<g[i][j];
      if(a-j>=1)cout<<" ";
    }
    cout<<endl;
  }
  
  return 0;
}

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

int main(){
  int a,m[101][101],b,c,d;
  cin >> a;
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      m[i][j]=0;
    }
  }
  for(int i=1;i<=a;i++){
    cin >> b >> c;
    for(int j=0;j<c;j++){
      cin >> d;
      m[i][d]=1;
    }
  }
  for(int i=1;i<=a;i++){
    for(int j=1;j<=a;j++){
      cout << m[i][j];
      if(j!=a)cout<< " ";
    }
    cout << endl;
  }
  return 0;
}

C++: #include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <queue>
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
int N,W;
int vx[]={1,0,-1,0};
int vy[]={0,1,0,-1};
int mt[102][102];
using namespace std;
void solve(){
    cin >> N ;
    int E,K;
    memset (mt,0,102*102);
    REP(i,N){
      cin >> E >> K;
      REP(j,K)
      {
        cin >> E;
        mt[i][E-1] = 1 ;
      }
    }
    REP(x,N){
      REP(y,N){
        cout << mt[x][y] ;
        if(x!=N-1&&y!= N-1)cout << ' '<<endl;
      }
      if(x!=N-1)cout << endl;
    }
}
int main(){

    solve();
}