이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define FOR(i, x, y) for (int i = x; i < y; i++)
typedef long long ll;
using namespace std;
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
int n;
long double r;
cin >> n >> r;
vector<pair<ll, int>> stars;
FOR(i, 0, n) {
long double x1, y1, x2, y2;
cin >> x1 >> y1 >> x2 >> y2;
if (x1 == x2) swap(x1, y1), swap(x2, y2);
long double v = x2 - x1;
long double m = (y1 - y2) / (x1 - x2);
long double c = y1 - m * x1;
if (m * m + c * c < 4 * (m * m + 1) * (c * c - r * r)) continue;
long double int_1 = (-2 * m * c + 2 * sqrt(m * m * c * c -
(m * m + 1) * (c * c - r * r))) /
(2 * m * m + 2);
long double int_2 = (-2 * m * c - 2 * sqrt(m * m * c * c -
(m * m + 1) * (c * c - r * r))) /
(2 * m * m + 2);
if ((int_1 - x1) / v > (int_2 - x1) / v) swap(int_1, int_2);
if ((int_2 - x1) / v < 0) continue;
ll in = max(0ll, ll(ceil((int_1 - x1) / v)));
ll out = ll(floor((int_2 - x1) / v));
stars.push_back({in, -1});
stars.push_back({out, 1});
}
sort(stars.begin(), stars.end());
int ans = 0, cnt = 0;
for (pair<int, int> i : stars) {
cnt -= i.second;
ans = max(ans, cnt);
}
cout << ans;
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |