# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
875883 |
2023-11-20T16:40:10 Z |
rainboy |
Wish (LMIO19_noras) |
C++17 |
|
104 ms |
9388 KB |
#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 = (ld) b * b - (ld) 4 * a * c;
if (d < 0)
continue;
d = sqrtl(d);
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.cpp: In function 'int main()':
noras.cpp:46:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
46 | scanf("%d%lld", &n, &r);
| ~~~~~^~~~~~~~~~~~~~~~~~
noras.cpp:52:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
52 | scanf("%lld%lld%lld%lld", &x1, &y1, &x2, &y2), x2 -= x1, y2 -= y1;
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2484 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2488 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2472 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2484 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2488 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2472 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
32 ms |
5744 KB |
Output is correct |
24 |
Correct |
30 ms |
5616 KB |
Output is correct |
25 |
Correct |
29 ms |
5712 KB |
Output is correct |
26 |
Correct |
30 ms |
5712 KB |
Output is correct |
27 |
Correct |
29 ms |
5312 KB |
Output is correct |
28 |
Correct |
29 ms |
5716 KB |
Output is correct |
29 |
Correct |
30 ms |
5876 KB |
Output is correct |
30 |
Correct |
29 ms |
5724 KB |
Output is correct |
31 |
Correct |
30 ms |
5868 KB |
Output is correct |
32 |
Correct |
50 ms |
6236 KB |
Output is correct |
33 |
Correct |
42 ms |
5900 KB |
Output is correct |
34 |
Correct |
41 ms |
5868 KB |
Output is correct |
35 |
Correct |
41 ms |
5972 KB |
Output is correct |
36 |
Correct |
41 ms |
5980 KB |
Output is correct |
37 |
Correct |
29 ms |
5292 KB |
Output is correct |
38 |
Correct |
30 ms |
5280 KB |
Output is correct |
39 |
Correct |
32 ms |
5352 KB |
Output is correct |
40 |
Correct |
29 ms |
5200 KB |
Output is correct |
41 |
Correct |
29 ms |
4996 KB |
Output is correct |
42 |
Correct |
30 ms |
5172 KB |
Output is correct |
43 |
Correct |
90 ms |
9300 KB |
Output is correct |
44 |
Correct |
96 ms |
9308 KB |
Output is correct |
45 |
Correct |
98 ms |
9388 KB |
Output is correct |
46 |
Correct |
95 ms |
9356 KB |
Output is correct |
47 |
Correct |
94 ms |
9348 KB |
Output is correct |
48 |
Correct |
82 ms |
8528 KB |
Output is correct |
49 |
Correct |
87 ms |
8508 KB |
Output is correct |
50 |
Correct |
89 ms |
8528 KB |
Output is correct |
51 |
Correct |
85 ms |
8276 KB |
Output is correct |
52 |
Correct |
83 ms |
8272 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2484 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2488 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2472 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
0 ms |
2396 KB |
Output is correct |
24 |
Correct |
1 ms |
2396 KB |
Output is correct |
25 |
Correct |
1 ms |
2504 KB |
Output is correct |
26 |
Correct |
1 ms |
2396 KB |
Output is correct |
27 |
Correct |
1 ms |
2396 KB |
Output is correct |
28 |
Correct |
1 ms |
2392 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2484 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2488 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2472 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
32 ms |
5744 KB |
Output is correct |
24 |
Correct |
30 ms |
5616 KB |
Output is correct |
25 |
Correct |
29 ms |
5712 KB |
Output is correct |
26 |
Correct |
30 ms |
5712 KB |
Output is correct |
27 |
Correct |
29 ms |
5312 KB |
Output is correct |
28 |
Correct |
29 ms |
5716 KB |
Output is correct |
29 |
Correct |
30 ms |
5876 KB |
Output is correct |
30 |
Correct |
29 ms |
5724 KB |
Output is correct |
31 |
Correct |
30 ms |
5868 KB |
Output is correct |
32 |
Correct |
50 ms |
6236 KB |
Output is correct |
33 |
Correct |
42 ms |
5900 KB |
Output is correct |
34 |
Correct |
41 ms |
5868 KB |
Output is correct |
35 |
Correct |
41 ms |
5972 KB |
Output is correct |
36 |
Correct |
41 ms |
5980 KB |
Output is correct |
37 |
Correct |
29 ms |
5292 KB |
Output is correct |
38 |
Correct |
30 ms |
5280 KB |
Output is correct |
39 |
Correct |
32 ms |
5352 KB |
Output is correct |
40 |
Correct |
29 ms |
5200 KB |
Output is correct |
41 |
Correct |
29 ms |
4996 KB |
Output is correct |
42 |
Correct |
30 ms |
5172 KB |
Output is correct |
43 |
Correct |
90 ms |
9300 KB |
Output is correct |
44 |
Correct |
96 ms |
9308 KB |
Output is correct |
45 |
Correct |
98 ms |
9388 KB |
Output is correct |
46 |
Correct |
95 ms |
9356 KB |
Output is correct |
47 |
Correct |
94 ms |
9348 KB |
Output is correct |
48 |
Correct |
82 ms |
8528 KB |
Output is correct |
49 |
Correct |
87 ms |
8508 KB |
Output is correct |
50 |
Correct |
89 ms |
8528 KB |
Output is correct |
51 |
Correct |
85 ms |
8276 KB |
Output is correct |
52 |
Correct |
83 ms |
8272 KB |
Output is correct |
53 |
Correct |
0 ms |
2396 KB |
Output is correct |
54 |
Correct |
1 ms |
2396 KB |
Output is correct |
55 |
Correct |
1 ms |
2504 KB |
Output is correct |
56 |
Correct |
1 ms |
2396 KB |
Output is correct |
57 |
Correct |
1 ms |
2396 KB |
Output is correct |
58 |
Correct |
1 ms |
2392 KB |
Output is correct |
59 |
Correct |
29 ms |
5756 KB |
Output is correct |
60 |
Correct |
32 ms |
5464 KB |
Output is correct |
61 |
Correct |
32 ms |
5460 KB |
Output is correct |
62 |
Correct |
31 ms |
5632 KB |
Output is correct |
63 |
Correct |
37 ms |
5460 KB |
Output is correct |
64 |
Correct |
46 ms |
5212 KB |
Output is correct |
65 |
Correct |
37 ms |
5456 KB |
Output is correct |
66 |
Correct |
37 ms |
5460 KB |
Output is correct |
67 |
Correct |
37 ms |
5468 KB |
Output is correct |
68 |
Correct |
45 ms |
6112 KB |
Output is correct |
69 |
Correct |
56 ms |
5972 KB |
Output is correct |
70 |
Correct |
48 ms |
6320 KB |
Output is correct |
71 |
Correct |
53 ms |
5972 KB |
Output is correct |
72 |
Correct |
46 ms |
5912 KB |
Output is correct |
73 |
Correct |
30 ms |
5200 KB |
Output is correct |
74 |
Correct |
32 ms |
5296 KB |
Output is correct |
75 |
Correct |
40 ms |
5712 KB |
Output is correct |
76 |
Correct |
30 ms |
5212 KB |
Output is correct |
77 |
Correct |
86 ms |
9152 KB |
Output is correct |
78 |
Correct |
85 ms |
9044 KB |
Output is correct |
79 |
Correct |
85 ms |
9044 KB |
Output is correct |
80 |
Correct |
88 ms |
9040 KB |
Output is correct |
81 |
Correct |
104 ms |
9040 KB |
Output is correct |
82 |
Correct |
87 ms |
9044 KB |
Output is correct |
83 |
Correct |
90 ms |
8704 KB |
Output is correct |
84 |
Correct |
86 ms |
8540 KB |
Output is correct |
85 |
Correct |
93 ms |
8688 KB |
Output is correct |
86 |
Correct |
94 ms |
8704 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2392 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
1 ms |
2484 KB |
Output is correct |
4 |
Correct |
1 ms |
2392 KB |
Output is correct |
5 |
Correct |
1 ms |
2488 KB |
Output is correct |
6 |
Correct |
1 ms |
2396 KB |
Output is correct |
7 |
Correct |
1 ms |
2396 KB |
Output is correct |
8 |
Correct |
0 ms |
2392 KB |
Output is correct |
9 |
Correct |
0 ms |
2472 KB |
Output is correct |
10 |
Correct |
0 ms |
2396 KB |
Output is correct |
11 |
Correct |
0 ms |
2396 KB |
Output is correct |
12 |
Correct |
0 ms |
2396 KB |
Output is correct |
13 |
Correct |
0 ms |
2396 KB |
Output is correct |
14 |
Correct |
1 ms |
2396 KB |
Output is correct |
15 |
Correct |
1 ms |
2396 KB |
Output is correct |
16 |
Correct |
1 ms |
2396 KB |
Output is correct |
17 |
Correct |
1 ms |
2396 KB |
Output is correct |
18 |
Correct |
1 ms |
2396 KB |
Output is correct |
19 |
Correct |
1 ms |
2396 KB |
Output is correct |
20 |
Correct |
1 ms |
2396 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
1 ms |
2396 KB |
Output is correct |
23 |
Correct |
32 ms |
5744 KB |
Output is correct |
24 |
Correct |
30 ms |
5616 KB |
Output is correct |
25 |
Correct |
29 ms |
5712 KB |
Output is correct |
26 |
Correct |
30 ms |
5712 KB |
Output is correct |
27 |
Correct |
29 ms |
5312 KB |
Output is correct |
28 |
Correct |
29 ms |
5716 KB |
Output is correct |
29 |
Correct |
30 ms |
5876 KB |
Output is correct |
30 |
Correct |
29 ms |
5724 KB |
Output is correct |
31 |
Correct |
30 ms |
5868 KB |
Output is correct |
32 |
Correct |
50 ms |
6236 KB |
Output is correct |
33 |
Correct |
42 ms |
5900 KB |
Output is correct |
34 |
Correct |
41 ms |
5868 KB |
Output is correct |
35 |
Correct |
41 ms |
5972 KB |
Output is correct |
36 |
Correct |
41 ms |
5980 KB |
Output is correct |
37 |
Correct |
29 ms |
5292 KB |
Output is correct |
38 |
Correct |
30 ms |
5280 KB |
Output is correct |
39 |
Correct |
32 ms |
5352 KB |
Output is correct |
40 |
Correct |
29 ms |
5200 KB |
Output is correct |
41 |
Correct |
29 ms |
4996 KB |
Output is correct |
42 |
Correct |
30 ms |
5172 KB |
Output is correct |
43 |
Correct |
90 ms |
9300 KB |
Output is correct |
44 |
Correct |
96 ms |
9308 KB |
Output is correct |
45 |
Correct |
98 ms |
9388 KB |
Output is correct |
46 |
Correct |
95 ms |
9356 KB |
Output is correct |
47 |
Correct |
94 ms |
9348 KB |
Output is correct |
48 |
Correct |
82 ms |
8528 KB |
Output is correct |
49 |
Correct |
87 ms |
8508 KB |
Output is correct |
50 |
Correct |
89 ms |
8528 KB |
Output is correct |
51 |
Correct |
85 ms |
8276 KB |
Output is correct |
52 |
Correct |
83 ms |
8272 KB |
Output is correct |
53 |
Correct |
29 ms |
5756 KB |
Output is correct |
54 |
Correct |
32 ms |
5464 KB |
Output is correct |
55 |
Correct |
32 ms |
5460 KB |
Output is correct |
56 |
Correct |
31 ms |
5632 KB |
Output is correct |
57 |
Correct |
37 ms |
5460 KB |
Output is correct |
58 |
Correct |
46 ms |
5212 KB |
Output is correct |
59 |
Correct |
37 ms |
5456 KB |
Output is correct |
60 |
Correct |
37 ms |
5460 KB |
Output is correct |
61 |
Correct |
37 ms |
5468 KB |
Output is correct |
62 |
Correct |
45 ms |
6112 KB |
Output is correct |
63 |
Correct |
56 ms |
5972 KB |
Output is correct |
64 |
Correct |
48 ms |
6320 KB |
Output is correct |
65 |
Correct |
53 ms |
5972 KB |
Output is correct |
66 |
Correct |
46 ms |
5912 KB |
Output is correct |
67 |
Correct |
30 ms |
5200 KB |
Output is correct |
68 |
Correct |
32 ms |
5296 KB |
Output is correct |
69 |
Correct |
40 ms |
5712 KB |
Output is correct |
70 |
Correct |
30 ms |
5212 KB |
Output is correct |
71 |
Correct |
86 ms |
9152 KB |
Output is correct |
72 |
Correct |
85 ms |
9044 KB |
Output is correct |
73 |
Correct |
85 ms |
9044 KB |
Output is correct |
74 |
Correct |
88 ms |
9040 KB |
Output is correct |
75 |
Correct |
104 ms |
9040 KB |
Output is correct |
76 |
Correct |
87 ms |
9044 KB |
Output is correct |
77 |
Correct |
90 ms |
8704 KB |
Output is correct |
78 |
Correct |
86 ms |
8540 KB |
Output is correct |
79 |
Correct |
93 ms |
8688 KB |
Output is correct |
80 |
Correct |
94 ms |
8704 KB |
Output is correct |
81 |
Correct |
0 ms |
2396 KB |
Output is correct |
82 |
Correct |
1 ms |
2396 KB |
Output is correct |
83 |
Correct |
1 ms |
2504 KB |
Output is correct |
84 |
Correct |
1 ms |
2396 KB |
Output is correct |
85 |
Correct |
1 ms |
2396 KB |
Output is correct |
86 |
Correct |
1 ms |
2392 KB |
Output is correct |
87 |
Correct |
54 ms |
6996 KB |
Output is correct |
88 |
Correct |
47 ms |
7000 KB |
Output is correct |
89 |
Correct |
50 ms |
7040 KB |
Output is correct |
90 |
Correct |
55 ms |
7008 KB |
Output is correct |
91 |
Correct |
49 ms |
6996 KB |
Output is correct |
92 |
Correct |
53 ms |
6928 KB |
Output is correct |
93 |
Correct |
48 ms |
7000 KB |
Output is correct |
94 |
Correct |
58 ms |
7324 KB |
Output is correct |
95 |
Correct |
58 ms |
7196 KB |
Output is correct |
96 |
Correct |
46 ms |
6940 KB |
Output is correct |
97 |
Correct |
33 ms |
6624 KB |
Output is correct |
98 |
Correct |
34 ms |
6484 KB |
Output is correct |
99 |
Correct |
47 ms |
6484 KB |
Output is correct |
100 |
Correct |
33 ms |
6544 KB |
Output is correct |
101 |
Correct |
35 ms |
6744 KB |
Output is correct |
102 |
Correct |
33 ms |
6516 KB |
Output is correct |
103 |
Correct |
34 ms |
6460 KB |
Output is correct |
104 |
Correct |
36 ms |
6412 KB |
Output is correct |
105 |
Correct |
38 ms |
6540 KB |
Output is correct |
106 |
Correct |
34 ms |
6480 KB |
Output is correct |