fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n,m;
  6. cin>>n>>m;
  7. int ms[n][n]={};
  8. for(int i=0; i<m; i++){
  9. int a,b;
  10. cin>>a>>b;
  11. a--;b--;
  12. ms[a][b]=1;
  13. ms[b][a]=1;
  14. }
  15. for(int i=0; i<n; i++){
  16. for(int j=0; j<n; j++)
  17. cout<<ms[i][j]<<" ";
  18. }
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 5288KB
stdin
5 3
1 3
2 3
2 5
stdout
0 0 1 0 0 0 0 1 0 1 1 1 0 0 0 0 0 0 0 0 0 1 0 0 0