Advertisement
savrasov

333

Oct 18th, 2017
377
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. //#include "stdafx.h"
  2.  
  3.  
  4. #include <algorithm>
  5. #include <iostream>
  6. #include <string>
  7. #include <cstring>
  8. #include <fstream>
  9. #include <cmath>
  10. #include <vector>
  11. #include <utility>
  12. #include <cstdlib>
  13. #include <deque>
  14. #include <queue>
  15. #include <iomanip>
  16. #include <numeric>
  17. #include <stack>
  18. #include <map>
  19. //#include <unordered_map>
  20. #include <set>
  21. //#include <unordered_set>
  22. #include <cmath>
  23. #include <list>
  24. #define mp make_pair
  25. #define pb push_back
  26. #define x first
  27. #define y second
  28. #define pnt pair<int, int>
  29. #define preturn(a) return cout << a << endl, 0
  30.  
  31. using namespace std;
  32.  
  33. typedef long long ll;
  34. typedef unsigned long long ull;
  35. typedef long double ld;
  36. typedef unsigned int uint;
  37. const int N = (int)250000, mdt = 1e7, limit = 1e8;
  38. const ld eps = 1e-8, eps1 = 1e-20, PI = 3.14159265358979323846264338, OOO = 1e100L, lim = sqrt(2e9 + 100);
  39. const ll OO = 1e18 * 8, mod = 1e9 + 7, md = 4294967291;
  40.  
  41. pair<pnt, pnt> a[10];
  42.  
  43. bool check_x(int v)
  44. {
  45. int m, b;
  46. m = b = 0;
  47. for (int i = 0; i < 4; i++)
  48. if (a[i].x.x <= v && a[i].y.x <= v)
  49. m++;
  50. else if (a[i].x.x >= v && a[i].y.x >= v)
  51. b++;
  52. else
  53. return 0;
  54. return (m == b);
  55. }
  56.  
  57. bool check_y(int v)
  58. {
  59. int m, b;
  60. m = b = 0;
  61. for (int i = 0; i < 4; i++)
  62. if (a[i].x.y <= v && a[i].y.y <= v)
  63. m++;
  64. else if (a[i].x.y >= v && a[i].y.y >= v)
  65. b++;
  66. else
  67. return 0;
  68. return (m == b);
  69. }
  70.  
  71. int main()
  72. {
  73. ios_base::sync_with_stdio(0);
  74. cin.tie();
  75. cout.tie();
  76. for (int i = 0; i < 4; i++)
  77. cin >> a[i].x.x >> a[i].x.y >> a[i].y.x >> a[i].y.y;
  78. for (int i = 0; i < 4; i++)
  79. if (check_x(a[i].x.x))
  80. return cout << "Vertical" << endl << a[i].x.x, 0;
  81. else if (check_x(a[i].x.x - 1))
  82. return cout << "Vertical" << endl << a[i].x.x - 1, 0;
  83. else if (check_x(a[i].y.x + 1))
  84. return cout << "Vertical" << endl << a[i].y.x + 1, 0;
  85. else if (check_y(a[i].x.y))
  86. return cout << "Horizontal" << endl << a[i].x.y, 0;
  87. else if (check_y(a[i].x.y - 1))
  88. return cout << "Horizontal" << endl << a[i].x.y - 1, 0;
  89. else if (check_y(a[i].y.y + 1))
  90. return cout << "Horizontal" << endl << a[i].y.y + 1, 0;
  91. cout << "Impossible";
  92. return 0;
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement