danielvitor23

Three Square

Nov 6th, 2021
1,405
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.11 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef pair<int, int> ii;
  4.  
  5. #define fi first
  6. #define se second
  7.  
  8. ii a[3];
  9.  
  10. int main() {
  11.   cin.tie(0)->sync_with_stdio(0);
  12.  
  13.   cin >> a[0].fi >> a[0].se;
  14.   cin >> a[1].fi >> a[1].se;
  15.   cin >> a[2].fi >> a[2].se;
  16.  
  17.   bool ok = false;
  18.   vector<int> v({0, 1, 2});
  19.   do {
  20.     vector<int> u = v;
  21.     for (int i : {0, 1}) {
  22.       for (int j : {0, 1}) {
  23.         for (int k : {0, 1}) {
  24.           if (i) swap(a[u[0]].fi, a[u[0]].se);
  25.           if (j) swap(a[u[1]].fi, a[u[1]].se);
  26.           if (k) swap(a[u[2]].fi, a[u[2]].se);
  27.           if (a[u[0]].fi + a[u[1]].fi == a[u[2]].se and
  28.               a[u[0]].se == a[u[1]].se and
  29.               a[u[2]].se == a[u[2]].fi+a[u[1]].se) {
  30.             ok = true;
  31.           }
  32.           if (i) swap(a[u[0]].fi, a[u[0]].se);
  33.           if (j) swap(a[u[1]].fi, a[u[1]].se);
  34.           if (k) swap(a[u[2]].fi, a[u[2]].se);
  35.           if (ok) break;
  36.         }
  37.         if (ok) break;
  38.       }
  39.       if (ok) break;
  40.     }
  41.     if (ok) break;
  42.   } while(next_permutation(v.begin(), v.end()));
  43.  
  44.   cout << (ok ? "YES\n" : "NO\n");
  45. }
Advertisement
Add Comment
Please, Sign In to add comment