Go: package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	g := make([][]int, n)
	for i := 0; i < n; i++ {
		g[i] = make([]int, n)
	}

	for i := 0; i < n; i++ {
		var u,k int
		fmt.Scan(&u)
		fmt.Scan(&k)
		for j := 0; j < k; j++ {
			var v int
			fmt.Scan(&v)
			g[u-1][v-1] = 1
		}
	}

	for i := 0; i < n; i++ {
		fmt.Print(g[i][0])
		for j := 1; j < n; j++ {
			fmt.Printf(" %d", g[i][j])
		}
		fmt.Println()
	}
}

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

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(0);

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

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


int main(){
	int n,k,m,j;
	cin >> n;
	int M[100][100] = {};
	for (int i = 0;i < n;i++) {
		cin >> m>>k;
		for (int l = 0;l < k;l++) {
			cin >> j;
			M[m - 1][j - 1] = 1;
		}
	}
	for (int i = 0;i < n;i++) {
		for (int l=0;l < n;l++) {
			if(l>0){
			    cout<<" ";
			    
			}
			cout << M[i][l] ;
		}
		cout << endl;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int g[200][200];

int main() {
    int n; cin >> n;
    rep(i, n){
        int x; cin >> x;
        int y; cin >> y;
        rep(j, y){
            int k; cin >> k;
            g[i+1][k] = 1;
        }
    }

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

    return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int main() {
    int n; cin >> n;
    vector<vector<int>> G(n + 1, vector<int>(n + 1, 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;
            G[u][v] = 1;
        }
    }

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

C++: #include<cstdio>
const short N_MAX = 105;
bool matrix[N_MAX][N_MAX];
int main(){
	int n;
	scanf("%d", &n);
	for(char i=0; i<n;i++){
		int degree, index;
		scanf("%u%u", &index, &degree);
		for(char j=0; j<degree; j++){
			int temp;
			scanf("%d", &temp);
			matrix[index-1][temp-1] = true;
		}
	}
	for(char r=0; r<n; r++){
		for(char c=0;c<n;c++){
			if(c!=0) printf(" ");
			printf("%d", matrix[r][c]);
		}
		printf("\n");
	}
	return 0;
}

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

int main()

{

  int k,v,n,i,j,m=0;

  scanf("%d",&n);

  int Adj[n][n];

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

  }
    
  }

  
  

  for(i=0; i<n; i++)
    {
      scanf("%d",&m);
      scanf("%d",&k);
      for(j=0; j<k; j++)
	{
	  scanf("%d",&v);
	  Adj[i][v-1]=1;
	}
      
    }
  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      printf("%d",Adj[i][j]);
      if(j!=n-1) printf(" ");
	

  }
    printf("\n");
  }
  
  
}

C++: 
#include <iostream>
using namespace std;
int main()
{
	int total,TotalOfConnectedNode,node,connectednode;
	int AM[101][101];
	for (int i = 0; i < 101; i++)
		for (int j = 0; j < 101; j++)
			AM[i][j] = 0;

	
	cin >> total;
	for (int i = 0; i < total; i++)//有向图
	{
		cin >> node>>TotalOfConnectedNode;
		if (TotalOfConnectedNode == 0) continue;
		for (int i = 0; i < TotalOfConnectedNode; i++)
		{
			cin >> connectednode;
			AM[node][connectednode] = 1;
			//AM[connectednode][node] = 1;无向图

		}
	}
	for (int i = 1; i <= total; i++)
	{		for (int j = 1; j <= total; j++)
			{	
			   if(j>1)
			    cout << " ";
			   cout<< AM[i][j];
			    
			}
		cout << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>
#include <bitset>
#include <sstream>
#define mop 1000000007

using namespace std;
int m[101][101] = {};

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


}

C++: #include <iostream>
using ll = long long;
using namespace std;
/* initialize */

/* main */
int main() {
    int n,u,k, v;
    int A[100][100];
    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 >> u >> k;
        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] << "\n";
    }
    return 0;
}

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

C++: #include<iostream>

int main() {
	int node_num, adj[100][100];

	std::cin >> node_num;

	for (int i = 0; i < node_num; i++)
		for (int j = 0; j < node_num; j++)
			adj[i][j] = 0;

	for (int i = 0; i < node_num; i++) {
		int node, num;
		std::cin >> node >> num;
		for (int j = 0; j < num; j++) {
			int n;
			std::cin >> n;
			adj[node - 1][n - 1] = 1;
		}
	}

	for (int i = 0; i < node_num; i++) {
		for (int j = 0; j < node_num; j++) {
			std::cout << adj[i][j] << (j != node_num - 1 ? " ":"");
		}
		std::cout << std::endl;
	}
}

C++: /*   _/                _/                 _/_/_/   _/
  _/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
   _/     _/    _/   _/     _/    _/  _/_/_/     _/
  _/     _/    _/   _/     _/    _/  _/    _/   _/
   _/_/   _/_/       _/_/   _/_/      _/_/     _/ */
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
using ll=long long;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=2e9;
const ll INF=1e18;
using P=pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int n,a,b,c,g[105][105]={};
  cin >> n;
  for(int i=0; i<n; i++) {
    cin >> a >> b;
    a--;
    for(int j=0; j<b; j++) {
      cin >> c;
      c--;
      g[a][c]=1;
    }
  }
  for(int i=0; i<n; i++) {
    for(int j=0; j<n-1; j++) {
      cout << g[i][j] << " ";
    }
    cout << g[i][n-1] << endl;
  }
}