Advertisement
Josif_tepe

Untitled

Dec 22nd, 2024
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3. using namespace std;
  4.  
  5. const int maxn = 100000;
  6. vector<int> graph[maxn];
  7. int main()
  8. {
  9.     int n, m;
  10.     cin >> n >> m;
  11.    
  12.     for(int i = 0; i < m; i++) {
  13.         int a, b;
  14.         cin >> a >> b;
  15.         graph[a].push_back(b);
  16.         graph[b].push_back(a);
  17.     }
  18.    
  19.     for(int i = 0; i < n; i++) {
  20.         for(int j = 0; j < graph[i].size(); j++) {
  21.             cout << i << " <--> " << graph[i][j] << endl;
  22.         }
  23.     }
  24.  
  25.     return 0;
  26.  
  27. }
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement