#include <math.h>
#include <stdio.h>
#define N 200000
long long max(long long a, long long b) { return a > b ? a : b; }
typedef long double ld;
typedef __int128_t L;
unsigned int X = 12345;
int rand_() {
return (X *= 3) >> 1;
}
long long tt[N * 2];
void sort(int *ii, int l, int r) {
while (l < r) {
int i = l, j = l, k = r, i_ = ii[l + rand_() % (r - l)], tmp;
while (j < k) {
int c = tt[ii[j]] != tt[i_] ? (tt[ii[j]] < tt[i_] ? -1 : 1) : (ii[j] & 1) - (i_ & 1);
if (c == 0)
j++;
else if (c < 0) {
tmp = ii[i], ii[i] = ii[j], ii[j] = tmp;
i++, j++;
} else {
k--;
tmp = ii[j], ii[j] = ii[k], ii[k] = tmp;
}
}
sort(ii, l, i);
l = k;
}
}
int main() {
static int ii[N * 2];
int n, n_, i, d, ans;
long long r;
scanf("%d%lld", &n, &r);
n_ = 0;
while (n--) {
long long x1, y1, x2, y2, a, b, c, t1, t2;
ld d;
scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2), x2 -= x1, y2 -= y1;
a = x2 * x2 + y2 * y2, b = (x1 * x2 + y1 * y2) * 2, c = x1 * x1 + y1 * y1 - r * r;
d = sqrtl((ld) b * b - (ld) 4 * a * c);
t1 = (-b - d) / 2 / a, t2 = (-b + d) / 2 / a;
while ((L) 2 * a * (t1 - 1) + b > 0 || ((L) a * (t1 - 1) + b) * (t1 - 1) + c <= 0)
t1--;
while ((L) 2 * a * t1 + b <= 0 && ((L) a * t1 + b) * t1 + c > 0)
t1++;
while ((L) 2 * a * (t2 + 1) + b <= 0 || ((L) a * (t2 + 1) + b) * (t2 + 1) + c <= 0)
t2++;
while ((L) 2 * a * t2 + b > 0 && ((L) a * t2 + b) * t2 + c > 0)
t2--;
t1 = max(t1, 0);
if (t1 <= t2)
tt[n_ << 1 | 0] = t1, tt[n_ << 1 | 1] = t2, n_++;
}
n = n_;
for (i = 0; i < n * 2; i++)
ii[i] = i;
sort(ii, 0, n * 2);
d = 0, ans = 0;
for (i = 0; i < n * 2; i++)
ans = max(ans, d += ((ii[i] & 1) == 0 ? 1 : -1));
printf("%d\n", ans);
return 0;
}
Compilation message
noras.c: In function 'main':
noras.c:46:2: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | scanf("%d%lld", &n, &r);
| ^~~~~~~~~~~~~~~~~~~~~~~
noras.c:52:3: warning: ignoring return value of 'scanf' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2), x2 -= x1, y2 -= y1;
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccLC8tuw.o: in function `main':
noras.c:(.text.startup+0x8fb): undefined reference to `sqrtl'
collect2: error: ld returned 1 exit status