Advertisement
Guest User

Untitled

a guest
Dec 19th, 2021
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.62 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long int
  4.  
  5. int main()
  6. {
  7.     ll n, m;
  8.     cin >> n >> m;
  9.     ll taka[n], aoki[n];
  10.     for (ll i = 0; i < n; i++) {
  11.         taka[i] = 0;
  12.         aoki[i] = 0;
  13.     }
  14.     for (ll i = 0; i < m; i++) {
  15.         ll a, b;
  16.         cin >> a >> b;
  17.         taka[a - 1]++;
  18.         taka[b - 1]++;
  19.     }
  20.     for (ll i = 0; i < m; i++) {
  21.         ll c, d;
  22.         cin >> c >> d;
  23.         aoki[c - 1]++;
  24.         aoki[d - 1]++;
  25.     }
  26.  
  27.     sort(taka, taka + n);
  28.     sort(aoki, aoki + n);
  29.  
  30.     bool poss = true;
  31.     for (ll i = 0; i < n; i++) {
  32.         if (taka[i] != aoki[i])
  33.             poss = false;
  34.     }
  35.  
  36.     if (poss)
  37.         cout << "Yes";
  38.     else
  39.         cout << "No";
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement