Advertisement
senb1

krsu 7488

Mar 1st, 2023
634
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.01 KB | None | 0 0
  1. /*
  2. by: senb1
  3. not my algo
  4. */
  5.  
  6. #include <bits/stdc++.h>
  7.  
  8. #define ll long long
  9. #define all(x) x.begin(), x.end()
  10. #define fr first
  11. #define sc second
  12. #define mk make_pair
  13. #define ar array
  14.  
  15. using namespace std;
  16.  
  17. const ll mod = 2023;
  18. const ll maxn = 1e3 + 5;
  19. const ll inf = 1e9 + 6;
  20.  
  21. int get(ar<int, 2> a, ar<int, 2> b, ar<int, 2> c) {
  22.     return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
  23. }
  24.  
  25. bool check(int a, int b, int c, int d) {
  26.     if (a > b)
  27.         swap(a, b);
  28.     if (c > d)
  29.         swap(c, d);
  30.     return max(a, c) <= min(b, d);
  31. }
  32.  
  33. bool ix(ar<int, 2> a, ar<int, 2> b, ar<int, 2> c, ar<int, 2> d) {
  34.     return check(a[0], b[0], c[0], d[0]) && check(a[1], b[1], c[1], d[1]) &&
  35.            get(a, b, c) * get(a, b, d) <= 0 && get(c, d, a) * get(c, d, b) <= 0;
  36. }
  37.  
  38. void solve() {
  39.     auto rd = [&](ar<int, 2> &a) { cin >> a[0] >> a[1]; };
  40.     auto check = [&](ar<int, 2> a, ar<int, 2> b) {
  41.         return (a[0] * b[1] == b[0] * a[1]);
  42.     };
  43.     ar<int, 2> a, b, c;
  44.     rd(a), rd(b);
  45.     ar<int, 2> d{};
  46.     int x;
  47.     cin >> x;
  48.     rd(c);
  49.     if (a[0] > b[0])
  50.         swap(a, b);
  51.     if (x) {
  52.         if (a == d || b == d) {
  53.             cout << "V\n";
  54.             return;
  55.         }
  56.         if (ix(a, b, d, d)) {
  57.             cout << "T\n";
  58.             return;
  59.         }
  60.         cout << "B\n";
  61.         return;
  62.     }
  63.     if (c[0] > d[0])
  64.         swap(c, d);
  65.     if (ix(a, b, c, d) && get(a, b, c) == 0 && get(a, b, d) == 0) {
  66.         cout << "I\n";
  67.         return;
  68.     }
  69.     if (a == d || a == c || b == d || b == c) {
  70.         cout << "V\n";
  71.         return;
  72.     }
  73.     if (ix(a, b, c, d) && get(a, b, c) == 0 || get(a, b, d) == 0 ||
  74.         get(c, d, a) == 0 || get(c, d, b) == 0) {
  75.         cout << "T\n";
  76.         return;
  77.     }
  78.     if (ix(a, b, c, d)) {
  79.         cout << "X\n";
  80.         return;
  81.     }
  82.  
  83.     cout << "B\n";
  84. }
  85.  
  86. int main() {
  87.     ios::sync_with_stdio(0);
  88.     cin.tie(0);
  89.  
  90.     int t = 1;
  91.     // cin >> t;
  92.     while (t--)
  93.         solve();
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement