Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- by: senb1
- not my algo
- */
- #include <bits/stdc++.h>
- #define ll long long
- #define all(x) x.begin(), x.end()
- #define fr first
- #define sc second
- #define mk make_pair
- #define ar array
- using namespace std;
- const ll mod = 2023;
- const ll maxn = 1e3 + 5;
- const ll inf = 1e9 + 6;
- int get(ar<int, 2> a, ar<int, 2> b, ar<int, 2> c) {
- return (b[0] - a[0]) * (c[1] - a[1]) - (b[1] - a[1]) * (c[0] - a[0]);
- }
- bool check(int a, int b, int c, int d) {
- if (a > b)
- swap(a, b);
- if (c > d)
- swap(c, d);
- return max(a, c) <= min(b, d);
- }
- bool ix(ar<int, 2> a, ar<int, 2> b, ar<int, 2> c, ar<int, 2> d) {
- return check(a[0], b[0], c[0], d[0]) && check(a[1], b[1], c[1], d[1]) &&
- get(a, b, c) * get(a, b, d) <= 0 && get(c, d, a) * get(c, d, b) <= 0;
- }
- void solve() {
- auto rd = [&](ar<int, 2> &a) { cin >> a[0] >> a[1]; };
- auto check = [&](ar<int, 2> a, ar<int, 2> b) {
- return (a[0] * b[1] == b[0] * a[1]);
- };
- ar<int, 2> a, b, c;
- rd(a), rd(b);
- ar<int, 2> d{};
- int x;
- cin >> x;
- rd(c);
- if (a[0] > b[0])
- swap(a, b);
- if (x) {
- if (a == d || b == d) {
- cout << "V\n";
- return;
- }
- if (ix(a, b, d, d)) {
- cout << "T\n";
- return;
- }
- cout << "B\n";
- return;
- }
- if (c[0] > d[0])
- swap(c, d);
- if (ix(a, b, c, d) && get(a, b, c) == 0 && get(a, b, d) == 0) {
- cout << "I\n";
- return;
- }
- if (a == d || a == c || b == d || b == c) {
- cout << "V\n";
- return;
- }
- if (ix(a, b, c, d) && get(a, b, c) == 0 || get(a, b, d) == 0 ||
- get(c, d, a) == 0 || get(c, d, b) == 0) {
- cout << "T\n";
- return;
- }
- if (ix(a, b, c, d)) {
- cout << "X\n";
- return;
- }
- cout << "B\n";
- }
- int main() {
- ios::sync_with_stdio(0);
- cin.tie(0);
- int t = 1;
- // cin >> t;
- while (t--)
- solve();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement