# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1023570 |
2024-07-15T02:45:07 Z |
vjudge1 |
Wish (LMIO19_noras) |
C++17 |
|
424 ms |
16840 KB |
#include <bits/stdc++.h>
using namespace std;
const long double maxd = 1e19;
long double sqrt128(__int128 x) {
long double l = 0, r = maxd;
for (int i=0; i<128; i++) {
long double mid = (l + r) / 2;
if (mid * mid <= x) {
l = mid;
} else {
r = mid;
}
}
return l;
}
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<long long, 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?
__int128 dx = c[i] - a[i], dy = d[i] - b[i];
__int128 A = dx * dx + dy * dy, B = 2 * (a[i] * dx + b[i] * dy), C = a[i] * a[i] + b[i] * b[i] - r * r;
__int128 D = B * B - 4 * A * C;
if (D >= 0) {
long double sd = sqrt128(D);
long double t1 = (-B + sd) / (2 * A);
long double t2 = (-B - sd) / (2 * A);
long long llt1 = ceil(min(t1, t2));
long long llt2 = floor(max(t1, t2));
// cout << min(t1, t2) << ' ' << max(t1, t2) << '\n';
// cout << llt1 << ' ' << llt2 << '\n';
if (llt1 <= llt2) {
evs.emplace_back(llt1, 0);
evs.emplace_back(llt2, 1);
}
}
}
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 >= 0) ans = max(ans, cnt);
if (rem) {
cnt--;
} else {
cnt++;
}
}
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 time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
544 KB |
Output is correct |
21 |
Correct |
2 ms |
496 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
544 KB |
Output is correct |
21 |
Correct |
2 ms |
496 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
197 ms |
8596 KB |
Output is correct |
24 |
Correct |
173 ms |
7880 KB |
Output is correct |
25 |
Correct |
194 ms |
9016 KB |
Output is correct |
26 |
Correct |
195 ms |
8212 KB |
Output is correct |
27 |
Correct |
194 ms |
5776 KB |
Output is correct |
28 |
Correct |
199 ms |
9452 KB |
Output is correct |
29 |
Correct |
211 ms |
7884 KB |
Output is correct |
30 |
Correct |
198 ms |
9416 KB |
Output is correct |
31 |
Correct |
197 ms |
8648 KB |
Output is correct |
32 |
Correct |
204 ms |
9160 KB |
Output is correct |
33 |
Correct |
195 ms |
8132 KB |
Output is correct |
34 |
Correct |
191 ms |
8732 KB |
Output is correct |
35 |
Correct |
197 ms |
9160 KB |
Output is correct |
36 |
Correct |
197 ms |
8272 KB |
Output is correct |
37 |
Correct |
196 ms |
5580 KB |
Output is correct |
38 |
Correct |
193 ms |
5580 KB |
Output is correct |
39 |
Correct |
187 ms |
5580 KB |
Output is correct |
40 |
Correct |
194 ms |
5584 KB |
Output is correct |
41 |
Correct |
194 ms |
5584 KB |
Output is correct |
42 |
Correct |
194 ms |
5768 KB |
Output is correct |
43 |
Correct |
424 ms |
15296 KB |
Output is correct |
44 |
Correct |
399 ms |
15552 KB |
Output is correct |
45 |
Correct |
415 ms |
16056 KB |
Output is correct |
46 |
Correct |
416 ms |
15808 KB |
Output is correct |
47 |
Correct |
409 ms |
16064 KB |
Output is correct |
48 |
Correct |
393 ms |
16320 KB |
Output is correct |
49 |
Correct |
390 ms |
16840 KB |
Output is correct |
50 |
Correct |
400 ms |
15044 KB |
Output is correct |
51 |
Correct |
361 ms |
15040 KB |
Output is correct |
52 |
Correct |
394 ms |
16056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
544 KB |
Output is correct |
21 |
Correct |
2 ms |
496 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
0 ms |
348 KB |
Output is correct |
24 |
Correct |
2 ms |
348 KB |
Output is correct |
25 |
Correct |
2 ms |
348 KB |
Output is correct |
26 |
Correct |
2 ms |
348 KB |
Output is correct |
27 |
Correct |
2 ms |
348 KB |
Output is correct |
28 |
Correct |
2 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
544 KB |
Output is correct |
21 |
Correct |
2 ms |
496 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
197 ms |
8596 KB |
Output is correct |
24 |
Correct |
173 ms |
7880 KB |
Output is correct |
25 |
Correct |
194 ms |
9016 KB |
Output is correct |
26 |
Correct |
195 ms |
8212 KB |
Output is correct |
27 |
Correct |
194 ms |
5776 KB |
Output is correct |
28 |
Correct |
199 ms |
9452 KB |
Output is correct |
29 |
Correct |
211 ms |
7884 KB |
Output is correct |
30 |
Correct |
198 ms |
9416 KB |
Output is correct |
31 |
Correct |
197 ms |
8648 KB |
Output is correct |
32 |
Correct |
204 ms |
9160 KB |
Output is correct |
33 |
Correct |
195 ms |
8132 KB |
Output is correct |
34 |
Correct |
191 ms |
8732 KB |
Output is correct |
35 |
Correct |
197 ms |
9160 KB |
Output is correct |
36 |
Correct |
197 ms |
8272 KB |
Output is correct |
37 |
Correct |
196 ms |
5580 KB |
Output is correct |
38 |
Correct |
193 ms |
5580 KB |
Output is correct |
39 |
Correct |
187 ms |
5580 KB |
Output is correct |
40 |
Correct |
194 ms |
5584 KB |
Output is correct |
41 |
Correct |
194 ms |
5584 KB |
Output is correct |
42 |
Correct |
194 ms |
5768 KB |
Output is correct |
43 |
Correct |
424 ms |
15296 KB |
Output is correct |
44 |
Correct |
399 ms |
15552 KB |
Output is correct |
45 |
Correct |
415 ms |
16056 KB |
Output is correct |
46 |
Correct |
416 ms |
15808 KB |
Output is correct |
47 |
Correct |
409 ms |
16064 KB |
Output is correct |
48 |
Correct |
393 ms |
16320 KB |
Output is correct |
49 |
Correct |
390 ms |
16840 KB |
Output is correct |
50 |
Correct |
400 ms |
15044 KB |
Output is correct |
51 |
Correct |
361 ms |
15040 KB |
Output is correct |
52 |
Correct |
394 ms |
16056 KB |
Output is correct |
53 |
Correct |
0 ms |
348 KB |
Output is correct |
54 |
Correct |
2 ms |
348 KB |
Output is correct |
55 |
Correct |
2 ms |
348 KB |
Output is correct |
56 |
Correct |
2 ms |
348 KB |
Output is correct |
57 |
Correct |
2 ms |
348 KB |
Output is correct |
58 |
Correct |
2 ms |
348 KB |
Output is correct |
59 |
Correct |
197 ms |
8648 KB |
Output is correct |
60 |
Correct |
171 ms |
9668 KB |
Output is correct |
61 |
Correct |
168 ms |
9068 KB |
Output is correct |
62 |
Correct |
166 ms |
5584 KB |
Output is correct |
63 |
Correct |
172 ms |
9492 KB |
Output is correct |
64 |
Correct |
169 ms |
9420 KB |
Output is correct |
65 |
Correct |
174 ms |
9348 KB |
Output is correct |
66 |
Correct |
181 ms |
8392 KB |
Output is correct |
67 |
Correct |
171 ms |
7944 KB |
Output is correct |
68 |
Correct |
205 ms |
8640 KB |
Output is correct |
69 |
Correct |
206 ms |
7864 KB |
Output is correct |
70 |
Correct |
208 ms |
7888 KB |
Output is correct |
71 |
Correct |
199 ms |
9160 KB |
Output is correct |
72 |
Correct |
201 ms |
8652 KB |
Output is correct |
73 |
Correct |
197 ms |
5584 KB |
Output is correct |
74 |
Correct |
189 ms |
8648 KB |
Output is correct |
75 |
Correct |
198 ms |
8284 KB |
Output is correct |
76 |
Correct |
208 ms |
5580 KB |
Output is correct |
77 |
Correct |
396 ms |
16684 KB |
Output is correct |
78 |
Correct |
396 ms |
16640 KB |
Output is correct |
79 |
Correct |
391 ms |
15808 KB |
Output is correct |
80 |
Correct |
403 ms |
15552 KB |
Output is correct |
81 |
Correct |
400 ms |
15044 KB |
Output is correct |
82 |
Correct |
402 ms |
15040 KB |
Output is correct |
83 |
Correct |
385 ms |
16068 KB |
Output is correct |
84 |
Correct |
399 ms |
15300 KB |
Output is correct |
85 |
Correct |
378 ms |
15252 KB |
Output is correct |
86 |
Correct |
401 ms |
15916 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
488 KB |
Output is correct |
4 |
Correct |
2 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
2 ms |
348 KB |
Output is correct |
7 |
Correct |
1 ms |
348 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
0 ms |
348 KB |
Output is correct |
12 |
Correct |
0 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
3 ms |
348 KB |
Output is correct |
15 |
Correct |
2 ms |
348 KB |
Output is correct |
16 |
Correct |
2 ms |
348 KB |
Output is correct |
17 |
Correct |
2 ms |
348 KB |
Output is correct |
18 |
Correct |
2 ms |
348 KB |
Output is correct |
19 |
Correct |
2 ms |
348 KB |
Output is correct |
20 |
Correct |
3 ms |
544 KB |
Output is correct |
21 |
Correct |
2 ms |
496 KB |
Output is correct |
22 |
Correct |
3 ms |
348 KB |
Output is correct |
23 |
Correct |
197 ms |
8596 KB |
Output is correct |
24 |
Correct |
173 ms |
7880 KB |
Output is correct |
25 |
Correct |
194 ms |
9016 KB |
Output is correct |
26 |
Correct |
195 ms |
8212 KB |
Output is correct |
27 |
Correct |
194 ms |
5776 KB |
Output is correct |
28 |
Correct |
199 ms |
9452 KB |
Output is correct |
29 |
Correct |
211 ms |
7884 KB |
Output is correct |
30 |
Correct |
198 ms |
9416 KB |
Output is correct |
31 |
Correct |
197 ms |
8648 KB |
Output is correct |
32 |
Correct |
204 ms |
9160 KB |
Output is correct |
33 |
Correct |
195 ms |
8132 KB |
Output is correct |
34 |
Correct |
191 ms |
8732 KB |
Output is correct |
35 |
Correct |
197 ms |
9160 KB |
Output is correct |
36 |
Correct |
197 ms |
8272 KB |
Output is correct |
37 |
Correct |
196 ms |
5580 KB |
Output is correct |
38 |
Correct |
193 ms |
5580 KB |
Output is correct |
39 |
Correct |
187 ms |
5580 KB |
Output is correct |
40 |
Correct |
194 ms |
5584 KB |
Output is correct |
41 |
Correct |
194 ms |
5584 KB |
Output is correct |
42 |
Correct |
194 ms |
5768 KB |
Output is correct |
43 |
Correct |
424 ms |
15296 KB |
Output is correct |
44 |
Correct |
399 ms |
15552 KB |
Output is correct |
45 |
Correct |
415 ms |
16056 KB |
Output is correct |
46 |
Correct |
416 ms |
15808 KB |
Output is correct |
47 |
Correct |
409 ms |
16064 KB |
Output is correct |
48 |
Correct |
393 ms |
16320 KB |
Output is correct |
49 |
Correct |
390 ms |
16840 KB |
Output is correct |
50 |
Correct |
400 ms |
15044 KB |
Output is correct |
51 |
Correct |
361 ms |
15040 KB |
Output is correct |
52 |
Correct |
394 ms |
16056 KB |
Output is correct |
53 |
Correct |
197 ms |
8648 KB |
Output is correct |
54 |
Correct |
171 ms |
9668 KB |
Output is correct |
55 |
Correct |
168 ms |
9068 KB |
Output is correct |
56 |
Correct |
166 ms |
5584 KB |
Output is correct |
57 |
Correct |
172 ms |
9492 KB |
Output is correct |
58 |
Correct |
169 ms |
9420 KB |
Output is correct |
59 |
Correct |
174 ms |
9348 KB |
Output is correct |
60 |
Correct |
181 ms |
8392 KB |
Output is correct |
61 |
Correct |
171 ms |
7944 KB |
Output is correct |
62 |
Correct |
205 ms |
8640 KB |
Output is correct |
63 |
Correct |
206 ms |
7864 KB |
Output is correct |
64 |
Correct |
208 ms |
7888 KB |
Output is correct |
65 |
Correct |
199 ms |
9160 KB |
Output is correct |
66 |
Correct |
201 ms |
8652 KB |
Output is correct |
67 |
Correct |
197 ms |
5584 KB |
Output is correct |
68 |
Correct |
189 ms |
8648 KB |
Output is correct |
69 |
Correct |
198 ms |
8284 KB |
Output is correct |
70 |
Correct |
208 ms |
5580 KB |
Output is correct |
71 |
Correct |
396 ms |
16684 KB |
Output is correct |
72 |
Correct |
396 ms |
16640 KB |
Output is correct |
73 |
Correct |
391 ms |
15808 KB |
Output is correct |
74 |
Correct |
403 ms |
15552 KB |
Output is correct |
75 |
Correct |
400 ms |
15044 KB |
Output is correct |
76 |
Correct |
402 ms |
15040 KB |
Output is correct |
77 |
Correct |
385 ms |
16068 KB |
Output is correct |
78 |
Correct |
399 ms |
15300 KB |
Output is correct |
79 |
Correct |
378 ms |
15252 KB |
Output is correct |
80 |
Correct |
401 ms |
15916 KB |
Output is correct |
81 |
Correct |
0 ms |
348 KB |
Output is correct |
82 |
Correct |
2 ms |
348 KB |
Output is correct |
83 |
Correct |
2 ms |
348 KB |
Output is correct |
84 |
Correct |
2 ms |
348 KB |
Output is correct |
85 |
Correct |
2 ms |
348 KB |
Output is correct |
86 |
Correct |
2 ms |
348 KB |
Output is correct |
87 |
Correct |
185 ms |
8396 KB |
Output is correct |
88 |
Correct |
177 ms |
12748 KB |
Output is correct |
89 |
Correct |
178 ms |
11976 KB |
Output is correct |
90 |
Correct |
181 ms |
13424 KB |
Output is correct |
91 |
Correct |
180 ms |
12492 KB |
Output is correct |
92 |
Correct |
178 ms |
13372 KB |
Output is correct |
93 |
Correct |
177 ms |
12224 KB |
Output is correct |
94 |
Correct |
180 ms |
11724 KB |
Output is correct |
95 |
Correct |
175 ms |
12704 KB |
Output is correct |
96 |
Correct |
177 ms |
11980 KB |
Output is correct |
97 |
Correct |
205 ms |
11852 KB |
Output is correct |
98 |
Correct |
188 ms |
11212 KB |
Output is correct |
99 |
Correct |
201 ms |
11468 KB |
Output is correct |
100 |
Correct |
199 ms |
11184 KB |
Output is correct |
101 |
Correct |
197 ms |
11716 KB |
Output is correct |
102 |
Correct |
197 ms |
10952 KB |
Output is correct |
103 |
Correct |
199 ms |
10952 KB |
Output is correct |
104 |
Correct |
202 ms |
10736 KB |
Output is correct |
105 |
Correct |
213 ms |
10952 KB |
Output is correct |
106 |
Correct |
198 ms |
11720 KB |
Output is correct |