Submission #1023555

#TimeUsernameProblemLanguageResultExecution timeMemory
1023555vjudge1Wish (LMIO19_noras)C++17
0 / 100
1 ms512 KiB
#include <bits/stdc++.h> using namespace std; const double eps = 1e-13; void solve() { int n; long long r; cin >> n >> r; vector<long long> a(n), b(n), c(n), d(n); for (int i=0; i<n; i++) cin >> a[i] >> b[i] >> c[i] >> d[i]; vector<pair<double, bool>> evs; for (int i=0; i<n; i++) { // p(t) = (a[i] + t * dx, b[i] + t * dy) // cari t sehingga (a[i] + t * dx)^2 + (b[i] + t * dy)^2 = r^2 // => a[i]^2 + t^2*dx^2 + 2*t*a[i]*dx + b[i]^2 + t^2*dy^2 + 2*t*b[i]*dy = r^2 // => t^2 * (dx^2 + dy^2) + t * (2*a[i]*dx + 2*b[i]*dy) + a[i]^2 + b[i]^2 - r^2 = 0 // => t^2 * A + t * B + C = 0 // pakai rumus akar persamaan kuadrat? long long dx = c[i] - a[i], dy = d[i] - b[i]; long long A = dx * dx + dy * dy, B = 2 * (a[i] * dx + b[i] * dy), C = a[i] * a[i] + b[i] * b[i] - r * r; long long D = B * B - 4 * A * C; if (D >= 0) { double sd = sqrt(D); double t1 = (-B + sd) / (2 * A); double t2 = (-B - sd) / (2 * A); evs.emplace_back(min(t1, t2), 0); evs.emplace_back(max(t1, t2), 1); // cout << i << ' ' << min(t1, t2) << ' ' << max(t1, t2) << '\n'; } } sort(evs.begin(), evs.end()); int ans = 0, cnt = 0; for (int i=0; i<(int)evs.size(); i++) { auto &[t, rem] = evs[i]; if (t < -eps) continue; // cout << t << ' '; // cout << floor(t) << ' ' << ceil(evs[i-1].first) << '\n'; if (floor(t) >= ceil(evs[i-1].first)) ans = max(ans, cnt); if (rem) { cnt--; } else { cnt++; } } // cout << '\n'; cout << ans << '\n'; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int tcs = 1; // cin >> tcs; while (tcs--) { 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...