Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //#include "stdafx.h"
- #include <algorithm>
- #include <iostream>
- #include <string>
- #include <cstring>
- #include <fstream>
- #include <cmath>
- #include <vector>
- #include <utility>
- #include <cstdlib>
- #include <deque>
- #include <queue>
- #include <iomanip>
- #include <numeric>
- #include <stack>
- #include <map>
- //#include <unordered_map>
- #include <set>
- //#include <unordered_set>
- #include <cmath>
- #include <list>
- #define mp make_pair
- #define pb push_back
- #define x first
- #define y second
- #define pnt pair<int, int>
- #define preturn(a) return cout << a << endl, 0
- using namespace std;
- typedef long long ll;
- typedef unsigned long long ull;
- typedef long double ld;
- typedef unsigned int uint;
- const int N = (int)250000, mdt = 1e7, limit = 1e8;
- const ld eps = 1e-8, eps1 = 1e-20, PI = 3.14159265358979323846264338, OOO = 1e100L, lim = sqrt(2e9 + 100);
- const ll OO = 1e18 * 8, mod = 1e9 + 7, md = 4294967291;
- pair<pnt, pnt> a[10];
- bool check_x(int v)
- {
- int m, b;
- m = b = 0;
- for (int i = 0; i < 4; i++)
- if (a[i].x.x <= v && a[i].y.x <= v)
- m++;
- else if (a[i].x.x >= v && a[i].y.x >= v)
- b++;
- else
- return 0;
- return (m == b);
- }
- bool check_y(int v)
- {
- int m, b;
- m = b = 0;
- for (int i = 0; i < 4; i++)
- if (a[i].x.y <= v && a[i].y.y <= v)
- m++;
- else if (a[i].x.y >= v && a[i].y.y >= v)
- b++;
- else
- return 0;
- return (m == b);
- }
- int main()
- {
- ios_base::sync_with_stdio(0);
- cin.tie();
- cout.tie();
- for (int i = 0; i < 4; i++)
- cin >> a[i].x.x >> a[i].x.y >> a[i].y.x >> a[i].y.y;
- for (int i = 0; i < 4; i++)
- if (check_x(a[i].x.x))
- return cout << "Vertical" << endl << a[i].x.x, 0;
- else if (check_x(a[i].x.x - 1))
- return cout << "Vertical" << endl << a[i].x.x - 1, 0;
- else if (check_x(a[i].y.x + 1))
- return cout << "Vertical" << endl << a[i].y.x + 1, 0;
- else if (check_y(a[i].x.y))
- return cout << "Horizontal" << endl << a[i].x.y, 0;
- else if (check_y(a[i].x.y - 1))
- return cout << "Horizontal" << endl << a[i].x.y - 1, 0;
- else if (check_y(a[i].y.y + 1))
- return cout << "Horizontal" << endl << a[i].y.y + 1, 0;
- cout << "Impossible";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement