#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
void setIO(string name = "") {
cin.tie(0)->sync_with_stdio(0); // see /general/fast-io
if (sz(name)) {
freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
freopen((name + ".out").c_str(), "w", stdout);
}
}
/*----------------------------------*/
typedef long long ll;
struct star
{
long long x, y;
long long dx, dy;
} stars[(int)2e5 + 1];
bool find_roots(int i, long double &root1, long double &root2, long long r) {
long long a, b, c;
a = stars[i].dx * stars[i].dx + stars[i].dy * stars[i].dy;
b = 2 * stars[i].dx * stars[i].x + 2 * stars[i].dy * stars[i].y;
c = stars[i].x * stars[i].x + stars[i].y * stars[i].y - r * r;
__int128 d = (__int128)b * b - (__int128) 4 * a * c;
if (d < 0) return false;
long double D = sqrt((long double)d);
root1 = (-b - D) / (2.L * a);
root2 = (-b + D) / (2.L * a);
return true;
}
bool cmp(const pair<long long, int>& a, const pair<long long, int>& b) {
if (a.first != b.first) return a.first < b.first;
return a.second > b.second;
}
int main() {
setIO("");
int n;
ll r;
cin >> n >> r;
vector<pair<long long, int>> interval;
for (int i = 0; i < n; ++i) {
cin >> stars[i].x >> stars[i].y >> stars[i].dx >> stars[i].dy;
stars[i].dx -= stars[i].x;
stars[i].dy -= stars[i].y;
long double root1, root2;
if (!find_roots(i, root1, root2, r)) continue;
long long start = max(0.L, ceil(root1)), finish = floor(root2);
if (start > finish) continue;
interval.push_back({start, 1});
interval.push_back({finish, -1});
}
sort(interval.begin(), interval.end(), cmp);
int mx = 0, curr = 0;
for (auto u : interval) {
// cout << u.first << " " << u.second << "\n";
curr += u.second;
mx = max(mx, curr);
}
cout << mx;
}
Compilation message
noras.cpp: In function 'void setIO(std::string)':
noras.cpp:8:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
8 | freopen((name + ".in").c_str(), "r", stdin); // see /general/input-output
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
noras.cpp:9:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
9 | freopen((name + ".out").c_str(), "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
380 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
380 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 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 |
1 ms |
380 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
380 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
59 ms |
8124 KB |
Output is correct |
24 |
Correct |
57 ms |
8100 KB |
Output is correct |
25 |
Correct |
57 ms |
8128 KB |
Output is correct |
26 |
Correct |
56 ms |
8172 KB |
Output is correct |
27 |
Correct |
65 ms |
6936 KB |
Output is correct |
28 |
Correct |
71 ms |
8252 KB |
Output is correct |
29 |
Correct |
55 ms |
8304 KB |
Output is correct |
30 |
Correct |
58 ms |
8368 KB |
Output is correct |
31 |
Correct |
57 ms |
8240 KB |
Output is correct |
32 |
Correct |
69 ms |
8252 KB |
Output is correct |
33 |
Correct |
87 ms |
8208 KB |
Output is correct |
34 |
Correct |
66 ms |
8236 KB |
Output is correct |
35 |
Correct |
67 ms |
8352 KB |
Output is correct |
36 |
Correct |
64 ms |
8232 KB |
Output is correct |
37 |
Correct |
60 ms |
7120 KB |
Output is correct |
38 |
Correct |
62 ms |
7088 KB |
Output is correct |
39 |
Correct |
51 ms |
6744 KB |
Output is correct |
40 |
Correct |
53 ms |
6828 KB |
Output is correct |
41 |
Correct |
54 ms |
6676 KB |
Output is correct |
42 |
Correct |
51 ms |
6732 KB |
Output is correct |
43 |
Correct |
153 ms |
17192 KB |
Output is correct |
44 |
Correct |
136 ms |
17140 KB |
Output is correct |
45 |
Correct |
137 ms |
17132 KB |
Output is correct |
46 |
Correct |
139 ms |
17216 KB |
Output is correct |
47 |
Correct |
155 ms |
17208 KB |
Output is correct |
48 |
Correct |
134 ms |
16112 KB |
Output is correct |
49 |
Correct |
132 ms |
16156 KB |
Output is correct |
50 |
Correct |
127 ms |
16096 KB |
Output is correct |
51 |
Correct |
135 ms |
16148 KB |
Output is correct |
52 |
Correct |
135 ms |
16096 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 |
1 ms |
380 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
380 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
340 KB |
Output is correct |
27 |
Correct |
2 ms |
344 KB |
Output is correct |
28 |
Correct |
1 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 |
1 ms |
380 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
380 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
59 ms |
8124 KB |
Output is correct |
24 |
Correct |
57 ms |
8100 KB |
Output is correct |
25 |
Correct |
57 ms |
8128 KB |
Output is correct |
26 |
Correct |
56 ms |
8172 KB |
Output is correct |
27 |
Correct |
65 ms |
6936 KB |
Output is correct |
28 |
Correct |
71 ms |
8252 KB |
Output is correct |
29 |
Correct |
55 ms |
8304 KB |
Output is correct |
30 |
Correct |
58 ms |
8368 KB |
Output is correct |
31 |
Correct |
57 ms |
8240 KB |
Output is correct |
32 |
Correct |
69 ms |
8252 KB |
Output is correct |
33 |
Correct |
87 ms |
8208 KB |
Output is correct |
34 |
Correct |
66 ms |
8236 KB |
Output is correct |
35 |
Correct |
67 ms |
8352 KB |
Output is correct |
36 |
Correct |
64 ms |
8232 KB |
Output is correct |
37 |
Correct |
60 ms |
7120 KB |
Output is correct |
38 |
Correct |
62 ms |
7088 KB |
Output is correct |
39 |
Correct |
51 ms |
6744 KB |
Output is correct |
40 |
Correct |
53 ms |
6828 KB |
Output is correct |
41 |
Correct |
54 ms |
6676 KB |
Output is correct |
42 |
Correct |
51 ms |
6732 KB |
Output is correct |
43 |
Correct |
153 ms |
17192 KB |
Output is correct |
44 |
Correct |
136 ms |
17140 KB |
Output is correct |
45 |
Correct |
137 ms |
17132 KB |
Output is correct |
46 |
Correct |
139 ms |
17216 KB |
Output is correct |
47 |
Correct |
155 ms |
17208 KB |
Output is correct |
48 |
Correct |
134 ms |
16112 KB |
Output is correct |
49 |
Correct |
132 ms |
16156 KB |
Output is correct |
50 |
Correct |
127 ms |
16096 KB |
Output is correct |
51 |
Correct |
135 ms |
16148 KB |
Output is correct |
52 |
Correct |
135 ms |
16096 KB |
Output is correct |
53 |
Correct |
1 ms |
212 KB |
Output is correct |
54 |
Correct |
1 ms |
348 KB |
Output is correct |
55 |
Correct |
1 ms |
340 KB |
Output is correct |
56 |
Correct |
1 ms |
340 KB |
Output is correct |
57 |
Correct |
2 ms |
344 KB |
Output is correct |
58 |
Correct |
1 ms |
340 KB |
Output is correct |
59 |
Correct |
60 ms |
8064 KB |
Output is correct |
60 |
Correct |
52 ms |
6964 KB |
Output is correct |
61 |
Correct |
51 ms |
7072 KB |
Output is correct |
62 |
Correct |
50 ms |
7232 KB |
Output is correct |
63 |
Correct |
54 ms |
7076 KB |
Output is correct |
64 |
Correct |
54 ms |
6912 KB |
Output is correct |
65 |
Correct |
54 ms |
6996 KB |
Output is correct |
66 |
Correct |
56 ms |
7108 KB |
Output is correct |
67 |
Correct |
57 ms |
7036 KB |
Output is correct |
68 |
Correct |
68 ms |
8380 KB |
Output is correct |
69 |
Correct |
69 ms |
8388 KB |
Output is correct |
70 |
Correct |
66 ms |
8388 KB |
Output is correct |
71 |
Correct |
70 ms |
8360 KB |
Output is correct |
72 |
Correct |
75 ms |
8472 KB |
Output is correct |
73 |
Correct |
55 ms |
6976 KB |
Output is correct |
74 |
Correct |
57 ms |
9168 KB |
Output is correct |
75 |
Correct |
57 ms |
8852 KB |
Output is correct |
76 |
Correct |
58 ms |
6840 KB |
Output is correct |
77 |
Correct |
136 ms |
16580 KB |
Output is correct |
78 |
Correct |
129 ms |
16568 KB |
Output is correct |
79 |
Correct |
139 ms |
16592 KB |
Output is correct |
80 |
Correct |
153 ms |
16488 KB |
Output is correct |
81 |
Correct |
138 ms |
16520 KB |
Output is correct |
82 |
Correct |
132 ms |
16428 KB |
Output is correct |
83 |
Correct |
132 ms |
16448 KB |
Output is correct |
84 |
Correct |
137 ms |
16436 KB |
Output is correct |
85 |
Correct |
130 ms |
16416 KB |
Output is correct |
86 |
Correct |
131 ms |
16496 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 |
1 ms |
380 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
380 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
0 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
336 KB |
Output is correct |
12 |
Correct |
1 ms |
256 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
344 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
340 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
59 ms |
8124 KB |
Output is correct |
24 |
Correct |
57 ms |
8100 KB |
Output is correct |
25 |
Correct |
57 ms |
8128 KB |
Output is correct |
26 |
Correct |
56 ms |
8172 KB |
Output is correct |
27 |
Correct |
65 ms |
6936 KB |
Output is correct |
28 |
Correct |
71 ms |
8252 KB |
Output is correct |
29 |
Correct |
55 ms |
8304 KB |
Output is correct |
30 |
Correct |
58 ms |
8368 KB |
Output is correct |
31 |
Correct |
57 ms |
8240 KB |
Output is correct |
32 |
Correct |
69 ms |
8252 KB |
Output is correct |
33 |
Correct |
87 ms |
8208 KB |
Output is correct |
34 |
Correct |
66 ms |
8236 KB |
Output is correct |
35 |
Correct |
67 ms |
8352 KB |
Output is correct |
36 |
Correct |
64 ms |
8232 KB |
Output is correct |
37 |
Correct |
60 ms |
7120 KB |
Output is correct |
38 |
Correct |
62 ms |
7088 KB |
Output is correct |
39 |
Correct |
51 ms |
6744 KB |
Output is correct |
40 |
Correct |
53 ms |
6828 KB |
Output is correct |
41 |
Correct |
54 ms |
6676 KB |
Output is correct |
42 |
Correct |
51 ms |
6732 KB |
Output is correct |
43 |
Correct |
153 ms |
17192 KB |
Output is correct |
44 |
Correct |
136 ms |
17140 KB |
Output is correct |
45 |
Correct |
137 ms |
17132 KB |
Output is correct |
46 |
Correct |
139 ms |
17216 KB |
Output is correct |
47 |
Correct |
155 ms |
17208 KB |
Output is correct |
48 |
Correct |
134 ms |
16112 KB |
Output is correct |
49 |
Correct |
132 ms |
16156 KB |
Output is correct |
50 |
Correct |
127 ms |
16096 KB |
Output is correct |
51 |
Correct |
135 ms |
16148 KB |
Output is correct |
52 |
Correct |
135 ms |
16096 KB |
Output is correct |
53 |
Correct |
60 ms |
8064 KB |
Output is correct |
54 |
Correct |
52 ms |
6964 KB |
Output is correct |
55 |
Correct |
51 ms |
7072 KB |
Output is correct |
56 |
Correct |
50 ms |
7232 KB |
Output is correct |
57 |
Correct |
54 ms |
7076 KB |
Output is correct |
58 |
Correct |
54 ms |
6912 KB |
Output is correct |
59 |
Correct |
54 ms |
6996 KB |
Output is correct |
60 |
Correct |
56 ms |
7108 KB |
Output is correct |
61 |
Correct |
57 ms |
7036 KB |
Output is correct |
62 |
Correct |
68 ms |
8380 KB |
Output is correct |
63 |
Correct |
69 ms |
8388 KB |
Output is correct |
64 |
Correct |
66 ms |
8388 KB |
Output is correct |
65 |
Correct |
70 ms |
8360 KB |
Output is correct |
66 |
Correct |
75 ms |
8472 KB |
Output is correct |
67 |
Correct |
55 ms |
6976 KB |
Output is correct |
68 |
Correct |
57 ms |
9168 KB |
Output is correct |
69 |
Correct |
57 ms |
8852 KB |
Output is correct |
70 |
Correct |
58 ms |
6840 KB |
Output is correct |
71 |
Correct |
136 ms |
16580 KB |
Output is correct |
72 |
Correct |
129 ms |
16568 KB |
Output is correct |
73 |
Correct |
139 ms |
16592 KB |
Output is correct |
74 |
Correct |
153 ms |
16488 KB |
Output is correct |
75 |
Correct |
138 ms |
16520 KB |
Output is correct |
76 |
Correct |
132 ms |
16428 KB |
Output is correct |
77 |
Correct |
132 ms |
16448 KB |
Output is correct |
78 |
Correct |
137 ms |
16436 KB |
Output is correct |
79 |
Correct |
130 ms |
16416 KB |
Output is correct |
80 |
Correct |
131 ms |
16496 KB |
Output is correct |
81 |
Correct |
1 ms |
212 KB |
Output is correct |
82 |
Correct |
1 ms |
348 KB |
Output is correct |
83 |
Correct |
1 ms |
340 KB |
Output is correct |
84 |
Correct |
1 ms |
340 KB |
Output is correct |
85 |
Correct |
2 ms |
344 KB |
Output is correct |
86 |
Correct |
1 ms |
340 KB |
Output is correct |
87 |
Correct |
72 ms |
8624 KB |
Output is correct |
88 |
Correct |
66 ms |
8536 KB |
Output is correct |
89 |
Correct |
67 ms |
8572 KB |
Output is correct |
90 |
Correct |
68 ms |
8540 KB |
Output is correct |
91 |
Correct |
73 ms |
8592 KB |
Output is correct |
92 |
Correct |
75 ms |
8504 KB |
Output is correct |
93 |
Correct |
64 ms |
8536 KB |
Output is correct |
94 |
Correct |
67 ms |
8652 KB |
Output is correct |
95 |
Correct |
67 ms |
8476 KB |
Output is correct |
96 |
Correct |
65 ms |
8508 KB |
Output is correct |
97 |
Correct |
63 ms |
8872 KB |
Output is correct |
98 |
Correct |
63 ms |
8864 KB |
Output is correct |
99 |
Correct |
63 ms |
8912 KB |
Output is correct |
100 |
Correct |
64 ms |
8984 KB |
Output is correct |
101 |
Correct |
60 ms |
8908 KB |
Output is correct |
102 |
Correct |
68 ms |
8800 KB |
Output is correct |
103 |
Correct |
67 ms |
8968 KB |
Output is correct |
104 |
Correct |
62 ms |
8904 KB |
Output is correct |
105 |
Correct |
63 ms |
8868 KB |
Output is correct |
106 |
Correct |
60 ms |
8844 KB |
Output is correct |