Advertisement
Pit_Anonim

R

Nov 25th, 2021
395
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.03 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 map[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.             map[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.                     map[x][y] = 1;
  30.                     map[y][x] = 1;
  31.                 }
  32.             }
  33.         }
  34.  
  35.     bool g = false;
  36.     for (int x = 0; x < a; x++) {
  37.         for (int y = 0; y < a; y++) {
  38.             if (map[x][y] == 0 && x != y) {
  39.                 g = true;
  40.             }
  41.         }
  42.     }
  43.  
  44.     if (!g) {
  45.         cout<<"YES"<<endl;
  46.     } else {
  47.         cout<<"NO"<<endl;
  48.     }
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement