Advertisement
Pit_Anonim

Q

Nov 25th, 2021
401
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.22 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7.     int a, b;
  8.     std::cin>>a>>b;
  9.     int matrix[a][a];
  10.  
  11.     std::vector<std::pair<int, int>> pairs;
  12.  
  13.     int j,k;
  14.     for (int x = 0; x < b; x++) {
  15.         std::cin>>j>>k;
  16.         pairs.push_back(std::pair<int,int>(j-1,k-1));
  17.     }
  18.  
  19.     for (int x = 0; x < a; x++) {
  20.         for (int y = 0; y < a; y++) {
  21.             matrix[x][y] = 0;
  22.         }
  23.     }
  24.  
  25.     for (int x = 0; x < a; x++)
  26.         for (int y = 0; y < a; y++) {
  27.             for (int l = 0; l < pairs.size(); l++) {
  28.                 if (pairs[l].first == x && pairs[l].second == y) {
  29.                     matrix[x][y] = 1;
  30.                     matrix[y][x] = 1;
  31.                 }
  32.             }
  33.         }
  34.  
  35.     std::vector<int> ans;
  36.  
  37.     int g = 0;
  38.     for (int x = 0; x < a; x++) {
  39.         for (int y = 0; y < a; y++) {
  40.             if (matrix[x][y]) {
  41.                 g++;
  42.             }
  43.         }
  44.         ans.push_back(g);
  45.         g=0;
  46.     }
  47.  
  48.     bool v = false;
  49.  
  50.     for (int x = 1; x < a; x++) {
  51.        if (ans[x] != ans[x-1]) {
  52.            v = true;
  53.        }
  54.     }
  55.  
  56.     if (!v) {
  57.         cout<<"YES"<<endl;
  58.     } else {
  59.         cout<<"NO"<<endl;
  60.     }
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement