#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const int MAXN = 2e5 + 10;
int n;
llint r;
vector<pair<llint, int>> event;
inline double dst(llint x, llint y) {
return sqrt((double)x * x + (double)y * y);
}
llint closest(llint x, llint y, llint dx, llint dy) {
llint lo = 0, hi = 1e9;
while (hi - lo >= 3) {
llint m1 = lo + (hi - lo) / 3;
llint m2 = hi - (hi - lo) / 3;
if (dst(x + m1 * dx, y + m1 * dy) > dst(x + m2 * dx, y + m2 * dy))
lo = m1;
else
hi = m2;
}
llint ret = lo;
for (llint i = lo + 1; i <= hi; ++i)
if (dst(x + i * dx, y + i * dy) < dst(x + ret * dx, y + ret * dy))
ret = i;
return ret;
}
llint find_lo(llint x, llint y, llint dx, llint dy, llint lo, llint hi) {
while (lo < hi) {
llint mid = (lo + hi) / 2;
if (dst(x + mid * dx, y + mid * dy) > r) lo = mid + 1; else hi = mid;
}
return lo;
}
llint find_hi(llint x, llint y, llint dx, llint dy, llint lo, llint hi) {
while (lo < hi) {
llint mid = (lo + hi) / 2 + 1;
if (dst(x + mid * dx, y + mid * dy) <= r) lo = mid; else hi = mid - 1;
}
return lo;
}
void find_interval(llint a, llint b, llint c, llint d) {
llint dx = c - a, dy = d - b;
llint k = closest(a, b, dx, dy);
//cerr << k << endl;
//cerr << dst(a + k * dx, b + k * dy) << " " << r << endl;
if (dst(a + k * dx, b + k * dy) > r) return;
llint lo = find_lo(a, b, dx, dy, 0, k);
llint hi = find_hi(a, b, dx, dy, k, 1e9);
//cerr << lo << " " << hi << endl;
if (hi < 0LL) return;
lo = max(lo, 0LL);
event.emplace_back(lo, 1);
event.emplace_back(hi + 1, -1);
}
int main(void) {
scanf("%d%lld", &n, &r);
for (int i = 0; i < n; ++i) {
llint a, b, c, d;
scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
find_interval(a, b, c, d);
}
sort(event.begin(), event.end());
int curr = 0, sol = 0;
for (auto &p : event) {
curr += p.second;
sol = max(sol, curr);
}
printf("%d\n", sol);
return 0;
}
Compilation message
noras.cpp: In function 'int main()':
noras.cpp:67:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
67 | scanf("%d%lld", &n, &r);
| ~~~~~^~~~~~~~~~~~~~~~~~
noras.cpp:70:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
70 | scanf("%lld%lld%lld%lld", &a, &b, &c, &d);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
312 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
0 ms |
304 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
316 KB |
Output is correct |
16 |
Correct |
3 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
316 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
312 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
0 ms |
304 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
316 KB |
Output is correct |
16 |
Correct |
3 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
316 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
184 ms |
5688 KB |
Output is correct |
24 |
Correct |
183 ms |
5820 KB |
Output is correct |
25 |
Correct |
182 ms |
5688 KB |
Output is correct |
26 |
Correct |
182 ms |
5688 KB |
Output is correct |
27 |
Correct |
161 ms |
3816 KB |
Output is correct |
28 |
Correct |
177 ms |
5800 KB |
Output is correct |
29 |
Correct |
177 ms |
5944 KB |
Output is correct |
30 |
Correct |
179 ms |
5804 KB |
Output is correct |
31 |
Correct |
181 ms |
5816 KB |
Output is correct |
32 |
Correct |
207 ms |
5804 KB |
Output is correct |
33 |
Correct |
205 ms |
5864 KB |
Output is correct |
34 |
Correct |
205 ms |
5832 KB |
Output is correct |
35 |
Correct |
204 ms |
5816 KB |
Output is correct |
36 |
Correct |
210 ms |
5852 KB |
Output is correct |
37 |
Correct |
171 ms |
3928 KB |
Output is correct |
38 |
Correct |
168 ms |
3896 KB |
Output is correct |
39 |
Correct |
160 ms |
3904 KB |
Output is correct |
40 |
Correct |
166 ms |
3844 KB |
Output is correct |
41 |
Correct |
161 ms |
3960 KB |
Output is correct |
42 |
Correct |
163 ms |
4032 KB |
Output is correct |
43 |
Correct |
416 ms |
11488 KB |
Output is correct |
44 |
Correct |
423 ms |
11676 KB |
Output is correct |
45 |
Correct |
421 ms |
11488 KB |
Output is correct |
46 |
Correct |
423 ms |
11520 KB |
Output is correct |
47 |
Correct |
424 ms |
11556 KB |
Output is correct |
48 |
Correct |
404 ms |
11164 KB |
Output is correct |
49 |
Correct |
414 ms |
11160 KB |
Output is correct |
50 |
Correct |
408 ms |
11064 KB |
Output is correct |
51 |
Correct |
405 ms |
11184 KB |
Output is correct |
52 |
Correct |
402 ms |
11128 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
312 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
0 ms |
304 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
316 KB |
Output is correct |
16 |
Correct |
3 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
316 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
316 KB |
Output is correct |
25 |
Correct |
2 ms |
340 KB |
Output is correct |
26 |
Correct |
2 ms |
340 KB |
Output is correct |
27 |
Correct |
3 ms |
340 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
312 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
0 ms |
304 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
316 KB |
Output is correct |
16 |
Correct |
3 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
316 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
184 ms |
5688 KB |
Output is correct |
24 |
Correct |
183 ms |
5820 KB |
Output is correct |
25 |
Correct |
182 ms |
5688 KB |
Output is correct |
26 |
Correct |
182 ms |
5688 KB |
Output is correct |
27 |
Correct |
161 ms |
3816 KB |
Output is correct |
28 |
Correct |
177 ms |
5800 KB |
Output is correct |
29 |
Correct |
177 ms |
5944 KB |
Output is correct |
30 |
Correct |
179 ms |
5804 KB |
Output is correct |
31 |
Correct |
181 ms |
5816 KB |
Output is correct |
32 |
Correct |
207 ms |
5804 KB |
Output is correct |
33 |
Correct |
205 ms |
5864 KB |
Output is correct |
34 |
Correct |
205 ms |
5832 KB |
Output is correct |
35 |
Correct |
204 ms |
5816 KB |
Output is correct |
36 |
Correct |
210 ms |
5852 KB |
Output is correct |
37 |
Correct |
171 ms |
3928 KB |
Output is correct |
38 |
Correct |
168 ms |
3896 KB |
Output is correct |
39 |
Correct |
160 ms |
3904 KB |
Output is correct |
40 |
Correct |
166 ms |
3844 KB |
Output is correct |
41 |
Correct |
161 ms |
3960 KB |
Output is correct |
42 |
Correct |
163 ms |
4032 KB |
Output is correct |
43 |
Correct |
416 ms |
11488 KB |
Output is correct |
44 |
Correct |
423 ms |
11676 KB |
Output is correct |
45 |
Correct |
421 ms |
11488 KB |
Output is correct |
46 |
Correct |
423 ms |
11520 KB |
Output is correct |
47 |
Correct |
424 ms |
11556 KB |
Output is correct |
48 |
Correct |
404 ms |
11164 KB |
Output is correct |
49 |
Correct |
414 ms |
11160 KB |
Output is correct |
50 |
Correct |
408 ms |
11064 KB |
Output is correct |
51 |
Correct |
405 ms |
11184 KB |
Output is correct |
52 |
Correct |
402 ms |
11128 KB |
Output is correct |
53 |
Correct |
0 ms |
212 KB |
Output is correct |
54 |
Correct |
3 ms |
316 KB |
Output is correct |
55 |
Correct |
2 ms |
340 KB |
Output is correct |
56 |
Correct |
2 ms |
340 KB |
Output is correct |
57 |
Correct |
3 ms |
340 KB |
Output is correct |
58 |
Correct |
3 ms |
340 KB |
Output is correct |
59 |
Correct |
184 ms |
5788 KB |
Output is correct |
60 |
Correct |
162 ms |
4012 KB |
Output is correct |
61 |
Correct |
166 ms |
4016 KB |
Output is correct |
62 |
Correct |
168 ms |
4316 KB |
Output is correct |
63 |
Correct |
167 ms |
4096 KB |
Output is correct |
64 |
Correct |
164 ms |
4160 KB |
Output is correct |
65 |
Correct |
168 ms |
4064 KB |
Output is correct |
66 |
Correct |
168 ms |
4096 KB |
Output is correct |
67 |
Correct |
166 ms |
4008 KB |
Output is correct |
68 |
Correct |
205 ms |
5988 KB |
Output is correct |
69 |
Correct |
203 ms |
5960 KB |
Output is correct |
70 |
Correct |
199 ms |
6012 KB |
Output is correct |
71 |
Correct |
221 ms |
6056 KB |
Output is correct |
72 |
Correct |
204 ms |
5944 KB |
Output is correct |
73 |
Correct |
166 ms |
3788 KB |
Output is correct |
74 |
Correct |
169 ms |
6024 KB |
Output is correct |
75 |
Correct |
177 ms |
5956 KB |
Output is correct |
76 |
Correct |
167 ms |
4008 KB |
Output is correct |
77 |
Correct |
394 ms |
11952 KB |
Output is correct |
78 |
Correct |
404 ms |
11988 KB |
Output is correct |
79 |
Correct |
402 ms |
11864 KB |
Output is correct |
80 |
Correct |
399 ms |
11892 KB |
Output is correct |
81 |
Correct |
395 ms |
11948 KB |
Output is correct |
82 |
Correct |
405 ms |
11420 KB |
Output is correct |
83 |
Correct |
402 ms |
11324 KB |
Output is correct |
84 |
Correct |
404 ms |
11524 KB |
Output is correct |
85 |
Correct |
398 ms |
11440 KB |
Output is correct |
86 |
Correct |
408 ms |
11384 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
212 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
2 ms |
312 KB |
Output is correct |
6 |
Correct |
2 ms |
340 KB |
Output is correct |
7 |
Correct |
2 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
0 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
304 KB |
Output is correct |
11 |
Correct |
0 ms |
304 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
3 ms |
340 KB |
Output is correct |
15 |
Correct |
2 ms |
316 KB |
Output is correct |
16 |
Correct |
3 ms |
340 KB |
Output is correct |
17 |
Correct |
2 ms |
340 KB |
Output is correct |
18 |
Correct |
2 ms |
340 KB |
Output is correct |
19 |
Correct |
2 ms |
340 KB |
Output is correct |
20 |
Correct |
2 ms |
340 KB |
Output is correct |
21 |
Correct |
2 ms |
316 KB |
Output is correct |
22 |
Correct |
2 ms |
340 KB |
Output is correct |
23 |
Correct |
184 ms |
5688 KB |
Output is correct |
24 |
Correct |
183 ms |
5820 KB |
Output is correct |
25 |
Correct |
182 ms |
5688 KB |
Output is correct |
26 |
Correct |
182 ms |
5688 KB |
Output is correct |
27 |
Correct |
161 ms |
3816 KB |
Output is correct |
28 |
Correct |
177 ms |
5800 KB |
Output is correct |
29 |
Correct |
177 ms |
5944 KB |
Output is correct |
30 |
Correct |
179 ms |
5804 KB |
Output is correct |
31 |
Correct |
181 ms |
5816 KB |
Output is correct |
32 |
Correct |
207 ms |
5804 KB |
Output is correct |
33 |
Correct |
205 ms |
5864 KB |
Output is correct |
34 |
Correct |
205 ms |
5832 KB |
Output is correct |
35 |
Correct |
204 ms |
5816 KB |
Output is correct |
36 |
Correct |
210 ms |
5852 KB |
Output is correct |
37 |
Correct |
171 ms |
3928 KB |
Output is correct |
38 |
Correct |
168 ms |
3896 KB |
Output is correct |
39 |
Correct |
160 ms |
3904 KB |
Output is correct |
40 |
Correct |
166 ms |
3844 KB |
Output is correct |
41 |
Correct |
161 ms |
3960 KB |
Output is correct |
42 |
Correct |
163 ms |
4032 KB |
Output is correct |
43 |
Correct |
416 ms |
11488 KB |
Output is correct |
44 |
Correct |
423 ms |
11676 KB |
Output is correct |
45 |
Correct |
421 ms |
11488 KB |
Output is correct |
46 |
Correct |
423 ms |
11520 KB |
Output is correct |
47 |
Correct |
424 ms |
11556 KB |
Output is correct |
48 |
Correct |
404 ms |
11164 KB |
Output is correct |
49 |
Correct |
414 ms |
11160 KB |
Output is correct |
50 |
Correct |
408 ms |
11064 KB |
Output is correct |
51 |
Correct |
405 ms |
11184 KB |
Output is correct |
52 |
Correct |
402 ms |
11128 KB |
Output is correct |
53 |
Correct |
184 ms |
5788 KB |
Output is correct |
54 |
Correct |
162 ms |
4012 KB |
Output is correct |
55 |
Correct |
166 ms |
4016 KB |
Output is correct |
56 |
Correct |
168 ms |
4316 KB |
Output is correct |
57 |
Correct |
167 ms |
4096 KB |
Output is correct |
58 |
Correct |
164 ms |
4160 KB |
Output is correct |
59 |
Correct |
168 ms |
4064 KB |
Output is correct |
60 |
Correct |
168 ms |
4096 KB |
Output is correct |
61 |
Correct |
166 ms |
4008 KB |
Output is correct |
62 |
Correct |
205 ms |
5988 KB |
Output is correct |
63 |
Correct |
203 ms |
5960 KB |
Output is correct |
64 |
Correct |
199 ms |
6012 KB |
Output is correct |
65 |
Correct |
221 ms |
6056 KB |
Output is correct |
66 |
Correct |
204 ms |
5944 KB |
Output is correct |
67 |
Correct |
166 ms |
3788 KB |
Output is correct |
68 |
Correct |
169 ms |
6024 KB |
Output is correct |
69 |
Correct |
177 ms |
5956 KB |
Output is correct |
70 |
Correct |
167 ms |
4008 KB |
Output is correct |
71 |
Correct |
394 ms |
11952 KB |
Output is correct |
72 |
Correct |
404 ms |
11988 KB |
Output is correct |
73 |
Correct |
402 ms |
11864 KB |
Output is correct |
74 |
Correct |
399 ms |
11892 KB |
Output is correct |
75 |
Correct |
395 ms |
11948 KB |
Output is correct |
76 |
Correct |
405 ms |
11420 KB |
Output is correct |
77 |
Correct |
402 ms |
11324 KB |
Output is correct |
78 |
Correct |
404 ms |
11524 KB |
Output is correct |
79 |
Correct |
398 ms |
11440 KB |
Output is correct |
80 |
Correct |
408 ms |
11384 KB |
Output is correct |
81 |
Correct |
0 ms |
212 KB |
Output is correct |
82 |
Correct |
3 ms |
316 KB |
Output is correct |
83 |
Correct |
2 ms |
340 KB |
Output is correct |
84 |
Correct |
2 ms |
340 KB |
Output is correct |
85 |
Correct |
3 ms |
340 KB |
Output is correct |
86 |
Correct |
3 ms |
340 KB |
Output is correct |
87 |
Correct |
182 ms |
5432 KB |
Output is correct |
88 |
Correct |
180 ms |
5444 KB |
Output is correct |
89 |
Correct |
180 ms |
5320 KB |
Output is correct |
90 |
Correct |
176 ms |
5428 KB |
Output is correct |
91 |
Correct |
176 ms |
5432 KB |
Output is correct |
92 |
Correct |
180 ms |
5548 KB |
Output is correct |
93 |
Correct |
181 ms |
5316 KB |
Output is correct |
94 |
Correct |
180 ms |
5524 KB |
Output is correct |
95 |
Correct |
186 ms |
5472 KB |
Output is correct |
96 |
Correct |
184 ms |
5360 KB |
Output is correct |
97 |
Correct |
187 ms |
6192 KB |
Output is correct |
98 |
Correct |
186 ms |
6204 KB |
Output is correct |
99 |
Correct |
190 ms |
6308 KB |
Output is correct |
100 |
Correct |
185 ms |
6424 KB |
Output is correct |
101 |
Correct |
185 ms |
6192 KB |
Output is correct |
102 |
Correct |
188 ms |
6308 KB |
Output is correct |
103 |
Correct |
198 ms |
6192 KB |
Output is correct |
104 |
Correct |
187 ms |
6264 KB |
Output is correct |
105 |
Correct |
191 ms |
6376 KB |
Output is correct |
106 |
Correct |
189 ms |
6300 KB |
Output is correct |