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

int main(){
  int n, u, k, x;
  int m[101][101]={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 <iostream>
using namespace std;
int main() {
    int n,p,q;
    cin>>n;
    int A[100][100]={0};
    for (int i=0;i<n;i++){
        cin>>q>>p;
        if (p==0)
            continue;
        for (int j=0;j<p;j++){
            int x;
            cin>>x;
            A[q][x-1]=1;
        }
    }
    
    
    for (int i=0;i<n;i++){
        for (int j=0;j<n;j++){
            cout<<A[i][j];
            if (j!=n-1)cout<<" "; 
        }
        cout<<endl;
    }
    return 0;
}

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

int main(void) {
	int n, u, k, s;
	cin >> n;
	bool table[102][102] = {};

	for (int i = 0;i <= n - 1;i++) {
		cin >> u >> k;
		for (int j = 0;j <= k - 1;j++) {
			cin >> s;
			table[u-1][s-1] = 1;
		}
	}

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

	return 0;
}

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

int N;
int M[101][101] = {};

int main(void) {

    cin >> N;

    for (int i = 0; i < N; ++i) {
        int v;
        int degree;
        cin >> v >> degree;

        for (int k = 0; k < degree; ++k) {
            int adj;
            cin >> adj;

            M[v][adj] = 1;
        }

    }

    for (int i = 1; i <= N; ++i) {
        for (int k = 1; k <= N; ++k) {
            cout << M[i][k];
            if (k != N) cout << " ";
        }
        cout << endl;
    }

    return 0;
}

C++: #include<stdio.h>
int main(){
  int a,b,d,j,i,c;
  int A[100][100]={};
  scanf("%d",&a);
  for(i=0;i<a;i++){
    scanf("%d%d",&b,&d);
    for(j=0;j<d;j++){
      scanf("%d",&c);
      A[b-1][c-1]=1;
    }
  }
  for(i=0;i<a;i++){
    for(j=0;j<a;j++){
      if(j==a-1)printf("%d",A[i][j]);
      else printf("%d ",A[i][j]);
    }
    printf("\n");
  }
}

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

int main() {

    int n , u , k , s;
    cin>> n ;
    vector<vector<int> > v(n,vector<int>(n,0));
    for(int i=0;i<n;i++){
    cin >> u >> k;
    for(int r=0;r<k;r++){
        cin >> s;
        v[u-1][s-1] = 1;

    }
    }
    for(int i=0;i<n;i++){

        for(int r=0;r<n;r++){
            cout << v[i][r] ; 
            if(r==n-1){}
            else {cout << " " ;}
        }
        cout << endl;
    }
}

C++: #include<iostream>
using namespace std;
static const int N = 100;

int main() {
  int M[N][N];  // 0 オリジンの配列
  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--;  // 0 オリジンへ変換
    for ( int j = 0; j < n; j++ ) {
      cin >> v;
      v--;  // 0 オリジンへ変換
      M[u][v] = 1;  // u と v の間に辺を張る
    }
  }

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

  return 0;
}

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

using NumNode = short;
using List = std::vector<NumNode>;
struct Node {
    NumNode idx;
    NumNode value;
    List list;
};
using Nodes = std::vector<Node>;
using Edge = bool;
using Row = std::vector<Edge>;
using Array = std::vector<Row>;

Nodes input_nodes(NumNode n_node);
List make_val2idx(Nodes nodes);
Array solve(Nodes nodes);
void print_graph_array(Array array);

int main() {
    NumNode n;
    std::cin >> n;
    Nodes nodes = input_nodes(n);
    const Array array = solve(nodes);
    print_graph_array(array);
}

Nodes input_nodes(NumNode n_node) {
    Nodes nodes{};
    for (NumNode i = 0; i < n_node; ++i) {
        NumNode u, k;
        std::cin >> u >> k;

        Node node{};
        node.idx = i;
        node.value = u;

        List list{};
        for (NumNode j = 0; j < k; ++j) {
            NumNode v;
            std::cin >> v;
            list.push_back(v);
        }
        node.list = list;
        nodes.push_back(node);
    }
    return nodes;
}

Array solve(Nodes nodes) {
    Array array{};
    List val2idx = make_val2idx(nodes);
    for (Node node : nodes) {
        Row row{};
        row.resize(nodes.size());
        for (NumNode node_dst : node.list) {
            const NumNode node_dst_idx = val2idx.at(node_dst);
            row.at(node_dst_idx) = true;
        }
        array.push_back(row);
    }
    return array;
}

List make_val2idx(Nodes nodes) {
    List val2idx{};
    NumNode value_max = std::numeric_limits<NumNode>::max();
    val2idx.resize(value_max);
    for (Node node : nodes) val2idx[node.value] = node.idx;
    return val2idx;
}

void print_graph_array(Array array) {
    for (Row row : array) {
        for (auto iter_edge = row.begin(); iter_edge != row.end();
             ++iter_edge) {
            std::cout << *iter_edge;
            if (iter_edge != end(row) - 1) std::cout << ' ';
        }
        std::cout << std::endl;
    }
}

C++: #include <stdio.h>

int main(){
    int Map[101][101];
    int N, u, k, temp;
    scanf("%d\n",&N);
    for (int ix = 0; ix < N; ix++)
        for (int jx = 0; jx < N; jx++)
            Map[ix][jx] = 0;
    for (int ix = 0; ix < N; ix++){
        scanf("%d %d",&u,&k);
        for (int kx = 0; kx < k; kx++){
            scanf("%d",&temp);
            Map[u-1][temp-1] = 1;
        }
    }
    for (int ix = 0; ix < N; ix++)
        for (int jx = 0; jx < N; jx++){
            if (jx == N-1) printf("%d\n",Map[ix][jx]);
            else printf("%d ",Map[ix][jx]);
        }
    return 0;
}

C++: #include <iostream>
#include <set>
using namespace std;
static const int N = 100;

int n;

set<int> G[100];

int main(int argc, char const *argv[])
{
    int k, u, g;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> k >> u;
        for (int j = 0; j < u; j++) {
            cin >> g;
            G[i].insert(g);
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (!G[i].empty()) {
                cout << ((j==0) ? "" : " ");
                cout << ((G[i].find(j+1) != G[i].end()) ? "1" : "0");
            } else {
                cout << ((j==0) ? "" : " ");
                cout << "0";
            }
        }
        cout << endl;
    }

    return 0;
}

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