Advertisement
Falak_Ahmed_Shakib

M - Graph

Mar 19th, 2021
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. int n,i,j;
  6.  
  7. cin>>n;
  8.  
  9. int ara[n+3][n+3];
  10.  
  11. for(i=1;i<=n;i++)
  12. {
  13. for(j=1;i<=n;i++)
  14. {
  15. ara[i][j]=0;
  16. }
  17. }
  18.  
  19. int a,b,t;
  20.  
  21. for( i=1;i<=n;i++)
  22. {
  23.  
  24. cin>>a>>t;
  25.  
  26. while(t--)
  27. {
  28.  
  29. cin>>b;
  30.  
  31. ara[a][b]=1;
  32. }
  33.  
  34.  
  35.  
  36.  
  37. }
  38.  
  39.  
  40. for( i=1;i<=n;i++)
  41. {
  42. for( j=1;j<=n;j++)
  43. {
  44. if(j==n)cout<<ara[i][j];
  45. else cout<<ara[i][j]<<" ";
  46.  
  47. }
  48. cout<<endl;
  49. }
  50.  
  51.  
  52.  
  53.  
  54.  
  55.  
  56.  
  57.  
  58.  
  59.  
  60.  
  61. }
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement