yordanganev

vectordemos

Apr 16th, 2020
374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.84 KB | None | 0 0
  1. #include <iostream>
  2. #include <queue>
  3.  
  4. using namespace std;
  5.  
  6. #define print(var) cout << #var << ": " << var << endl;
  7.  
  8. int main() {
  9.     unsigned int tests;
  10.     cin >> tests;
  11.    
  12.     for (unsigned int test = 0; test < tests; test++) {
  13.        
  14.         int readRows, citiesCount, K;
  15.         cin >> citiesCount >> readRows;
  16.  
  17.         citiesCount;
  18.         print(citiesCount);
  19.         print(readRows)
  20.  
  21.         vector<vector<int>> cities;
  22.        
  23.         for (int city = 0; city < citiesCount; city++) {
  24.             vector<int> v = {};
  25.             cities.push_back(v);
  26.         }
  27.  
  28.         for (int rows = 0; rows < readRows; rows++) {
  29.             int start, end;
  30.             cin >> start >> end;
  31.             print(start);
  32.             print(end);
  33.             cities[start - 1].push_back(end-1);
  34.             cities[end - 1].push_back(start - 1);
  35.         }
  36.         cin >> K;
  37.         for (int city = 0; city < citiesCount; city++) {
  38.             cout << city+1 << " => " << cities[city].size() << endl;
  39.         }
  40.  
  41.     }
  42. }
Advertisement
Add Comment
Please, Sign In to add comment