SHARE
TWEET

GRAF

a guest Nov 12th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #define MAXN 1000
  4. using namespace std;
  5.  
  6.  
  7. int main()
  8. {
  9.     std::vector<int>edge[MAXN+1];
  10.     int m,n,a,b;
  11.     int father[MAXN+1];
  12.     bool visit[MAXN+1];
  13.     std::cin>>m>>n;
  14.     for(int i = 1; i <= n; i++)
  15.     {
  16.         std::cin>>a>>b;
  17.         edge[a].push_back(b);
  18.         edge[b].push_back(a);
  19.     }
  20.     //DFS,BFS
  21.     cout << "Lista sasiedztwa\n";
  22.     for(int i =1 ; i <= m ; i++)
  23.     {
  24.         for(int j = 0; j < edge[i].size() ; j++)
  25.         {
  26.             cout << edge[i][j] << ",";
  27.         }
  28.         cout << "\n";
  29.     }
  30.  
  31.  
  32.     return 0;
  33. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top