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>
#include<string>
#include<vector>
#include<cstdio>
#include<sstream>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
int G[101][101];
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;
G[u][v]=1;
}
}
for(int i=1;i<=n;i++){
	for(int j=1;j<=n;j++){
	cout<<G[i][j];
	(j==n)?cout<<endl:cout<<" ";
	}
}
return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int adjacency_matrices[n][n];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            adjacency_matrices[i][j] = 0;
    int vertex;
    int degree;
    for(int i = 0; i < n; i++)
    {
        cin >> vertex;
        cin >> degree;
        int to_v;
        for(int j = 0; j < degree; j++)
        {
            cin >> to_v;
            adjacency_matrices[vertex - 1][to_v - 1] = 1;
        }
    }

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

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

int a[101][101] = {0}; //???????????????u??¨u?????£??\?????????????????????v  u??????v???????????£???????????°1

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

  int u,k,v;
  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 << " ";
    }
    cout <<  endl;
  }
}

C++: #include<iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  int i;
  int a[150][150];
  int x,y;
  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      a[x][y]=0;
    }
  }

  for (i = 0; i < n; i++) {
    int l;
    cin >> l;
    int k;
    cin >> k;
    int j;
    for (j = 0; j < k; j++) {
      int m=0;
      cin >> m;
      a[l-1][m-1]=1;
    }

  }

  for (x = 0; x < n; x++) {
    for (y = 0; y < n; y++) {
      printf("%d ",a[x][y]);
    }printf("?\n");
  }

  return 0;
}

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

using namespace std;

static const int N = 100;

int main()
{
    int M[N][N];

    int num, vertexId, numOfEdge, targetVertex;

    scanf("%d", &num);

    for (int i = 0; i < num; i++) {
        for (int j = 0; j < num; j++) {
            M[i][j] = 0;
        }
    }

    for (int i = 0; i < num; i++) {
        scanf("%d %d", &vertexId, &numOfEdge);
        vertexId--; //change to idx
        for (int j = 0; j < numOfEdge; j++) {
            scanf("%d", &targetVertex);
            targetVertex--;
            M[vertexId][targetVertex] = 1;
        }
    }

    for (int i = 0; i < num; i++) {
        for (int j =0; j < num; j++) {
            if (j) cout << " ";
            cout << M[i][j];
        }
        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) {cout << 1 <<" "; hantei=1;}
            }
            if(hantei==0) cout <<0<<" ";
        }cout << endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(){
  int n;
  cin >> n;
  bool graph[n][n] ;

  for(int i = 0; i < n; i++) for(int j = 0; j < n; j++) graph[i][j] = false;

  int v,k,v1;
  for(int i = 0; i < n; i++){
    cin >> v >> k;
    v--; //0index
    for(int j = 0; j < k; j++){
      cin >> v1;
      v1 --; //0index
      graph[v][v1] = true;
    }
  }

  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(graph[i][j]) cout << 1;
      else cout << 0 ;

      if(j == n-1) cout << endl;
      else cout << ' ';
    }
  }
  return 0;
}

C++: #include<stdio.h>
typedef struct{
  int u;
  int k;
  int v[100];
}Graph;

main(){
  int i,j,n;
  int a[100][100];
  Graph node[100];
  scanf("%d",&n);

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

  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      a[i][j]=0;
    }
    for(j=0;j<node[i].k;j++){
      a[i][node[i].v[j]-1] = 1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      printf("%d",a[i][j]);
      if(j<n)printf(" ");
    }
    if(i<n)printf("\n");
  }

  return 0;
}

C++: #include <iostream>
#include <array>
#include <algorithm>

const int size = 1005;
using matrix = std::array<std::array<int, size>, size>;

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


  matrix a;
  std::for_each(a.begin(), a.end(), [](auto x){x.fill(0);});

  auto nn = n;
  while (nn != 0)
    {
      int i, k;
      std::cin >> i >> k;
      while (k != 0)
        {
          int j;
          std::cin >> j;
          a[i-1][j-1] = 1;
          --k;
        }
      --nn;
    }

  for (int i=0; i<n; ++i)
    {
      for (int j=0; j<n; ++j)
        {
          if (j) std::cout << ' ';
          std::cout << a[i][j];
        }
      std::cout << std::endl;
    }
}

C++: #include <iostream>

using namespace std;

int main()
{
  int n, k[102], v[101][102] = {0}, i, j, l, a;

  cin >> n;
  for (i = 0; i < n; i++) {
    cin >> a;
    cin >> k[i];
    for (j = 0; j < k[i]; j++) {
      cin >> v[i][j + 1];
    }
  }

  for (i = 0; i < n; i++) {
    for (j = 0; j < n; j++) {
      if (k[i] == 0) {
        for (l = v[i][j - 1]; l < n - 1; l++) {
          printf("0 ");
        }
        printf("0\n");
        break;
      }
      else {
        if (v[i][j] != 0) {
          k[i]--;
          for (l = v[i][j - 1]; l < v[i][j] - 1; l++) {
            printf("0 ");
          }
          if (v[i][j] == n) {
            printf("1\n");
            break;
          }
          else {
            printf("1 ");
          }
        }
      }
    }
  }

  return 0;
}

C++: #include <iostream>
#include <stdio.h>

using namespace std;

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

	int** gmtrx = new int*[n];
	for(int i=0; i<n; ++i){
		gmtrx[i] = new int[n];
		for(int j=0; j<n; ++j){
			gmtrx[i][j] = 0;
		}
	}

	for(int i=0; i<n; ++i){
		int v, num, a;
		scanf("%d %d",&v,&num);
		for(int j=0; j<num; ++j){
			scanf("%d",&a);
			gmtrx[v-1][a-1] = 1;
		}

	}

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

	for(int i=0; i<n; ++i){
		delete[] gmtrx[i];
	}
	delete[] gmtrx;

	return 0;
}