fork download
  1. //#pragma GCC optimize("O3", "unroll-loops")
  2. //#pragma GCC target("avx2", "bmi", "bmi2", "lzcnt", "popcnt")
  3.  
  4. #include <bits/stdc++.h>
  5. #define ldb long double
  6. //#define double ldb
  7. #define db double
  8. #define unomap unordered_map
  9. #define unoset unordered_set
  10. #define endl '\n'
  11. #define str string
  12. #define strstr stringstream
  13. #define sz(a) (int)a.size()
  14. #define ll long long
  15. //#define int ll
  16. #define pii pair <int, int>
  17. #define pll pair <ll, ll>
  18. #define Unique(a) a.resize(unique(all(a)) - a.begin())
  19. #define ull unsigned ll
  20. #define fir first
  21. #define sec second
  22. #define idc cin.ignore()
  23. #define lb lower_bound
  24. #define ub upper_bound
  25. #define all(s) s.begin(), s.end()
  26. #define rev reverse
  27. #define gcd __gcd
  28. #define pushb push_back
  29. #define popb pop_back
  30. #define pushf push_front
  31. #define popf pop_front
  32. #define mul2x(a, x) a << x
  33. #define div2x(a, x) a >> x
  34. #define lcm(a, b) (a / __gcd(a, b) * b)
  35. #define log_base(x, base) log(x) / log(base)
  36. #define debug clog << "No errors!"; exit(0);
  37. #define forw(i, a, b) for (int i = a; i <= b; ++i)
  38. #define forw2(i, a, b) for (ll i = a; i <= b; ++i)
  39. #define fors(i, a, b) for (int i = a; i >= b; --i)
  40. #define fors2(i, a, b) for (ll i = a; i >= b; --i)
  41. #define pqueue priority_queue
  42. #define sqrt sqrtl
  43. #define popcount __builtin_popcountll
  44. #define want_digit(x) cout << fixed << setprecision(x);
  45. #define excuting_time 1000.0 * clock() / CLOCKS_PER_SEC
  46. using namespace std;
  47. const int MOD = 1e9 + 7; // 998244353
  48. const int inf = 1e9;
  49. const ll INF = 1e18;
  50. const int N = 2e5;
  51. const int N2 = 1e3;
  52.  
  53. mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
  54. ll random(const ll &L, const ll &R)
  55. {
  56. return uniform_int_distribution<ll> (L, R) (rng);
  57. }
  58.  
  59. struct point
  60. {
  61. int x, y;
  62. };
  63.  
  64. struct rect
  65. {
  66. point a, b;
  67. };
  68.  
  69. int n;
  70. rect v[N + 5];
  71. int sum[N2 + 5][N2 + 5];
  72.  
  73. void sub1()
  74. {
  75. memset(sum, 0, sizeof(sum));
  76. forw (i, 1, n + 1)
  77. {
  78. int x_mn, x_mx, y_mn, y_mx;
  79. x_mn = min(v[i].a.x, v[i].b.x);
  80. x_mx = max(v[i].a.x, v[i].b.x);
  81. y_mn = min(v[i].a.y, v[i].b.y);
  82. y_mx = max(v[i].a.y, v[i].b.y);
  83.  
  84. forw (j, x_mn, x_mx) forw (k, y_mn, y_mx)
  85. ++sum[j][k];
  86. }
  87.  
  88. forw (i, 1, 20) forw (j, 1, 20)
  89. if (sum[i][j] >= n)
  90. {
  91. cout << i << ' ' << j << endl;
  92. return;
  93. }
  94. cout << "-1\n";
  95. }
  96.  
  97. void sub2()
  98. {
  99. memset(sum, 0, sizeof(sum));
  100. forw (i, 1, n + 1)
  101. {
  102. int x_mn, x_mx, y_mn, y_mx;
  103. x_mn = min(v[i].a.x, v[i].b.x);
  104. x_mx = max(v[i].a.x, v[i].b.x);
  105. y_mn = min(v[i].a.y, v[i].b.y);
  106. y_mx = max(v[i].a.y, v[i].b.y);
  107.  
  108. // cout << i << ' ' << x_mn << ' ' << y_mn << ' ' << x_mx << ' ' << y_mx << endl;
  109.  
  110. ++sum[x_mn][y_mn];
  111. --sum[x_mx + 1][y_mn];
  112. --sum[x_mn][y_mx + 1];
  113. ++sum[x_mx + 1][y_mx + 1];
  114. }
  115.  
  116. forw (i, 1, N2) forw (j, 1, N2)
  117. {
  118. sum[i][j] += sum[i - 1][j] + sum[i][j - 1] - sum[i - 1][j - 1];
  119. if (sum[i][j] >= n)
  120. {
  121. cout << i << ' ' << j << endl;
  122. return;
  123. }
  124. }
  125. cout << "-1\n";
  126. }
  127.  
  128. void solve()
  129. {
  130. cin >> n;
  131. forw (i, 1, n + 1)
  132. cin >> v[i].a.x >> v[i].a.y >> v[i].b.x >> v[i].b.y;
  133. sub1();
  134. }
  135.  
  136. /*
  137. 2
  138. 1 1 2 3
  139. 2 2 3 1
  140. 3 6 0 4
  141. */
  142.  
  143. int32_t main()
  144. {
  145. ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  146. srand(time(NULL));
  147. #define name "test"
  148. /*
  149.   if (fopen(name".INP", "r"))
  150.   {
  151.   freopen(name".INP", "r", stdin);
  152.   freopen(name".OUT", "w", stdout);
  153.   }
  154.   */
  155. int numTest = 1;
  156. // cin >> numTest;
  157. while (numTest--)
  158. {
  159. solve();
  160. }
  161. return 0;
  162. }
  163.  
Success #stdin #stdout 0.01s 7744KB
stdin
Standard input is empty
stdout
1 1