fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. int main (){
  5. int n;
  6. cin >> n;
  7.  
  8. vector<vector<int>> matriks(n + 1, vector<int>(n + 1, 0));
  9. for (int i = 1; i <= n; i++){
  10. int u, k;
  11. cin >> u >> k;
  12. for (int j = 1; j <= k; j++){
  13. int v;
  14. cin >> v;
  15. matriks[u][v] = 1;
  16. }
  17. }
  18.  
  19. for (int i = 1; i <= n; i++){
  20. for (int j = 1; j <= n; j++){
  21. cout << matriks[i][j];
  22. if (j < n) cout << " ";
  23. }
  24. cout << "\n";
  25. }
  26.  
  27. }
Success #stdin #stdout 0s 5316KB
stdin
4
1 2 2 4
2 1 4
3 0
4 1 3
stdout
0 1 0 1
0 0 0 1
0 0 0 0
0 0 1 0