Advertisement
Pit_Anonim

S

Nov 25th, 2021
404
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 n, m;
  8.     cin>>n>>m;
  9.  
  10.     std::pair<int, int> a[m];
  11.  
  12.     for (int i = 0; i < m; i++) {
  13.         cin>>a[i].first>>a[i].second;
  14.         a[i].first--;
  15.         a[i].second--;
  16.     }
  17.  
  18.     vector<int> h;
  19.  
  20.     bool r = false;
  21.  
  22.     int matrix[n][n];
  23.  
  24.     for (int x = 0; x < n; x++) {
  25.         for (int y = 0; y < n; y++) {
  26.             for (int i = 0; i < m; i++) {
  27.                 if (a[i].first == x && a[i].second == y) {
  28.                     r = true;
  29.                     matrix[x][y] = 1;
  30.                     break;
  31.                 }
  32.             }
  33.  
  34.             if (!r) matrix[x][y] = 0;
  35.             r = false;
  36.         }
  37.     }
  38.  
  39.     bool g = false;
  40.     for (int x = 0; x < n; x++) {
  41.         for (int y = 0; y < n; y++) {
  42.             if (matrix[x][y] == 0 && x != y && matrix[y][x] == 0) {
  43.                 g = true;
  44.             }
  45.         }
  46.     }
  47.  
  48.     if (!g) {
  49.         cout<<"YES"<<endl;
  50.     } else {
  51.         cout<<"NO"<<endl;
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement