Advertisement
welleyth

3982. From adjacency list to adjacency matrix

Dec 26th, 2020
862
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. /********************
  2. * Problem: 3982.
  3. * Theme: Graphs
  4. */
  5. #include <bits/stdc++.h>
  6.  
  7. using namespace std;
  8.  
  9. #define int long long
  10. #define mp make_pair
  11. #define pb push_back
  12. #define ALL(A) A.begin(),A.end()
  13. #define RALL(A) A.rbegin(),A.rend()
  14. #define FOR(i,a,b) for(int i=(a);i<(b);i++)
  15.  
  16. typedef vector<int> VI;
  17. typedef vector<pair<int,int> > VII;
  18. typedef vector<VI> VVI;
  19.  
  20. const long double PI=acos(-1);
  21. const int INF=(int)1e18;
  22. const int MOD=(int)1e9+7;
  23. const int N = 1e3;
  24.  
  25. int m[101][101];
  26.  
  27. signed main()
  28. {
  29.     ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
  30.     //freopen("input.txt","r",stdin);
  31.     //freopen("output.txt","w",stdout);
  32.     //freopen("reform.in","r",stdin);
  33.     //freopen("reform.out","w",stdout);
  34.  
  35.     int n;
  36.     cin >> n;
  37.  
  38.     int t;
  39.  
  40.     int a;
  41.  
  42.     for(int i=0;i<n;i++)
  43.     {
  44.         cin >> t;
  45.         while(t--)
  46.         {
  47.             cin >> a;
  48.             m[i][a-1]=1;
  49.         }
  50.     }
  51.  
  52.     for(int i=0;i<n;i++)
  53.     {
  54.         for(int j=0;j<n;j++)
  55.         {
  56.             cout << m[i][j] << " ";
  57.         }
  58.         cout << "\n";
  59.     }
  60.  
  61.     return 0;
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement