Submission #670721

#TimeUsernameProblemLanguageResultExecution timeMemory
670721thiago_bastosWish (LMIO19_noras)C++17
0 / 100
14 ms332 KiB
#include "bits/stdc++.h" using namespace std; #define INF 1000000000 #define INFLL 1000000000000000000ll #define EPS 1e-9 #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define pb push_back #define fi first #define sc second using i64 = long long; using u64 = unsigned long long; using ld = long double; using ii = pair<int, int>; #define double ld int n, radius; double closest(int a, int b, int c, int d) { if(1ll*a*a+1ll*b*b <= 1ll * radius*radius) return 0; double l = 0, r = 1e5; while(fabs(l - r) > EPS) { double L = (2 * l + r) / 3.0, R = (2 * r + l) / 3.0; if(hypot(a + L * c, b + L * d) > hypot(a + R * c, b + R * d)) l = L; else r = R; } return r; } double firstSec(int a, int b, int c, int d, double k) { double l = 0, r = k; while(fabs(l - r) > EPS) { double m = (l + r) / 2; if(hypot(a + m * c, b + m * d) <= radius) r = m; else l = m; } return r; } double secondSec(int a, int b, int c, int d, double k) { double l = k, r = 1e5; while(fabs(l - r) > EPS) { double m = (l + r) / 2; if(hypot(a + m * c, b + m * d) > radius) r = m; else l = m; } return r; } void solve() { cin >> n >> radius; set<ii> sweep; int opening = 0, ans = 0; for(int i = 1; i <= n; ++i) { int a, b, c, d; cin >> a >> b >> c >> d; c -= a, d -= b; double k = closest(a, b, c, d); double l = firstSec(a, b, c, d, k); double r = secondSec(a, b, c, d, k); if(hypot(a + k * c, b + k * d) > radius) continue; int L = max(1, (int)ceil(l)), R = floor(r); if(L <= R) { sweep.emplace(l, -i); sweep.emplace(r, i); } } for(auto [x, k] : sweep) { opening += k < 0 ? 1 : -1; ans = max(ans, opening); } cout << ans << '\n'; } int main() { ios_base :: sync_with_stdio(false); cin.tie(0); int t = 1; //cin >> t; while(t--) solve(); return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...