nq1s788

список смежности и перебор соседей

Feb 21st, 2026
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.58 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <map>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <unordered_set>
  7. #include <set>
  8.  
  9. using namespace std;
  10.  
  11. int main() {
  12.     ///список ребер в список смежности
  13.     int n, m;
  14.     cin >> n >> m;
  15.     vector<vector<int>> g(n); //список смежности
  16.     for (int i = 0; i < m; i++) {
  17.         int x, y;
  18.         cin >> x >> y;
  19.         x--, y--;
  20.         g[x].push_back(y);
  21.         g[y].push_back(x);
  22.     }
  23.  
  24.     for (auto e : g[h]) {
  25.         ///e -- сосед h
  26.     }
  27.     return 0;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment