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<cstdio>
#include<iostream>
using namespace std;
const int MAXN = 100+10 ;

int a[MAXN][MAXN];

int main(void)
{
    int n,u,v,t;
    cin>>n;
    for(int i = 1; i <= n; ++i)
    {
        cin>>u>>t;
        for(int j = 1; j <= t; ++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]<<'\n';
    }
}

C++: #include <iostream>
#include <vector>
using namespace std;
vector<vector<int>> adjlist;
vector<vector<int>> adjmatrix;
void input(int n){
  for(int i=0;i<n;i++){
    vector<int> list;
    int ln;
    cin>>ln;
    list.push_back(ln);
    cin>>ln;
    list.push_back(ln);
    for(int j=0;j<ln;j++){
      int an;
      cin>>an;
      list.push_back(an);
    }
    adjlist.push_back(list);
  }
}

void mk_am(int n){
  adjmatrix=vector<vector<int>>(n,vector<int>(n,0));
  for(vector<int> list:adjlist){
    for(int i=0;i<list[1];i++){
      adjmatrix[list[0]-1][list[2+i]-1]=1;
    }
  }
}
 
void print(int n){
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout<<adjmatrix[i][j];
      if(j!=n-1) cout<<' ';
    }
    cout<<endl;
  }
}
int main(){
  int n;
  cin>>n;
  input(n);
  mk_am(n);
  print(n);
  return 0;
}

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

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

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

int main()
{
    int M[N][N];
    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--;
            for(int j=0;j<k;j++){
                cin>>v;
                v--;
                M[u][v]=1;
            }
    }
    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>
#define SIZE 100

using namespace std;

int main(void) {

	int n, c, v;
	int G[SIZE][SIZE];
	int A[SIZE][SIZE];

	cin >> 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 >> v;
		cin >> c;
		for (int j = 0; j < c; j++) {
			cin >> G[i][j];
			int tmp = G[i][j];
			if (tmp > 0) {
				A[i][tmp - 1] = 1;
			}
		}
	}

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

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

int main() {
	int verNum;
	int vertexs[100][100];

	for (int i = 0; i < 100; i++)
		for (int j = 0; j < 100; j++)
			vertexs[i][j] = 0;
	cin >> verNum;
	for (int i = 0; i < verNum; i++) {
		int num; cin >> num; num--;
		int outNum;	cin >> outNum;
		for (int j = 0; j < outNum; j++) {
			int outVertex; cin >> outVertex;
			vertexs[i][--outVertex] = 1;
		}
	}

	for (int i = 0; i < verNum; i++) {
		for (int j = 0; j < verNum; j++) {
			if (j) cout << " ";
			cout << vertexs[i][j];
		}
		cout << endl;
	}
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    vector<vector<int> > a(n + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= n; i++) {
        int u, k;
        cin >> u >> k;
        for (int j = 0; j < k; j++) {
            int v;
            cin >> v;
            a[u][v] = 1;
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            cout << a[i][j] << (j != n ? ' ' : '\n');
        }
    }
    return 0;
}

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

int main(void) {
    int n;
    cin >> n;
    vector<int> A(n*n,0);

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

    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            cout << A[i*n+j];
            if(j<n-1){
                cout << " ";
            } else {cout << endl;}
        }
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
static const int N=100;
int main(){
   int M[N][N];
   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--;
       for(int j=0;j<k;j++)
       {
           cin>>v;
           v--;
           M[u][v]=1;
       }
   }
   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>
using namespace std;
#define MAX 101

int main(void){
  int n, u, k, v, Adj[MAX][MAX];
  cin >> n;
  for(int i=1; i<=n; i++){
    cin >> u >> k;
    //cout << u << " " << k << endl;
    for(int j=1; j<=n; j++){
      Adj[i][j] = 0;
      //if(j-1) cout << " ";
      //cout << Adj[i][j];
    }
    //cout << endl;
    for(int j=0; j<k; j++){
      cin >> v;
      //cout << (j ? " " : "") << v;
      Adj[u][v] = 1;
    }
    //cout << endl;
    for(int j=1; j<=n; j++){
      if(j-1) cout << " ";
      cout << Adj[i][j];
    }
    cout << endl;
  }

  return 0;
}

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

int main(){
    int n;
    std::cin >> n;
    std::vector<int> Adj[n];
    //input_graph
    int u, k, v;
    for(int i=0; i<n; i++){
        std::cin >> u >> k;
        for(int j=0; j<k; j++){
            std::cin >> v;
            Adj[u-1].push_back(v);
        }
    }

    //input_A
    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++){
        int len = Adj[i].size();
        for(int j=0; j<len; j++){
            A[i][Adj[i][j]-1] = 1;
        }
    }

    //output_A
    for(int i=0; i<n; i++){
        for(int j=0; j<n; j++){
            if(j+1==n)  std::cout << A[i][j] << '\n';
            else        std::cout << A[i][j] << " ";
        }
    }
    return 0;
}