Advertisement
GerONSo

4 ЛКШ wa5

Apr 14th, 2019
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.58 KB | None | 0 0
  1. #define pragma
  2.  
  3. #ifdef pragma
  4. #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
  5. //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  6. #endif // pragma
  7.  
  8. #include<bits/stdc++.h>
  9. #include <ext/pb_ds/assoc_container.hpp>
  10. #include <ext/pb_ds/tree_policy.hpp>
  11.  
  12. #define ll long long
  13. #define all(x) begin(x), end(x)
  14. #define pb push_back
  15. #define x first
  16. #define y second
  17. #define int long long
  18. #define zero(two) memset(two, 0, sizeof(two))
  19.  
  20. using namespace std;
  21. using namespace __gnu_pbds;
  22.  
  23.  
  24. typedef vector<int> vi;
  25. typedef vector<bool> vb;
  26. typedef pair<int, int> pii;
  27. typedef long double ld;
  28. typedef vector<vi> matrix;
  29. template<typename T>
  30. using kawaii_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
  31.  
  32. const ld PI = atan2(0, -1);
  33.  
  34. void seriy() {
  35. ios::sync_with_stdio(0);
  36. cin.tie(0);
  37. cout.tie(0);
  38. cout << fixed << setprecision(10);
  39. #if _offline
  40. freopen("input.txt", "r", stdin);
  41. freopen("output.txt", "w", stdout);
  42. #endif
  43. }
  44.  
  45. const int MAXN = 2e3 + 10;
  46. const int INF = 1e18 + 7;
  47. const int MAXLOG = 20;
  48. const int MOD = 998244353;
  49. const int BASE = 47;
  50.  
  51. struct seg {
  52. pii a, b;
  53. };
  54.  
  55. bool cross(seg a, seg b) {
  56. if(a.a.x != a.b.x) {
  57. swap(a, b);
  58. }
  59. if(a.a.y <= b.a.y && a.b.y >= b.a.y || a.b.y <= b.a.y && a.a.y >= b.a.y) {
  60. if(a.a.x >= b.a.x && a.a.x <= b.b.x || a.a.x >= b.b.x && a.a.x <= b.a.x) {
  61. return 1;
  62. }
  63. }
  64. return 0;
  65. }
  66.  
  67. signed main() {
  68. seriy();
  69. int n;
  70. cin >> n;
  71. int cr[n][n];
  72. zero(cr);
  73. vi hor, ver;
  74. vector<seg> segs;
  75. for(int i = 0; i < n; i++) {
  76. int x, y, x1, y1;
  77. cin >> x >> y >> x1 >> y1;
  78. if(x == x1) {
  79. ver.pb(i);
  80. }
  81. else {
  82. hor.pb(i);
  83. }
  84. segs.pb({{x, y}, {x1, y1}});
  85. }
  86. for(auto i : ver) {
  87. for(auto j : hor) {
  88. cr[i][j] = cross(segs[i], segs[j]);
  89. cr[j][i] = cross(segs[i], segs[j]);
  90. }
  91. }
  92. int cnt = n;
  93. while(1) {
  94. int mx = 0, maxi;
  95. for(int i = 0; i < n; i++) {
  96. int sum = 0;
  97. for(int j = 0; j < n; j++) {
  98. sum += cr[i][j];
  99. }
  100. if(sum > mx) {
  101. mx = sum;
  102. maxi = i;
  103. }
  104. }
  105. if(mx == 0) {
  106. break;
  107. }
  108. for(int i = 0; i < n; i++) {
  109. cr[i][maxi] = 0;
  110. cr[maxi][i] = 0;
  111. }
  112. cnt--;
  113. }
  114. cout << cnt;
  115. return 0;
  116. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement