#include <bits/stdc++.h>
using namespace std;
#define big __int128_t
// #define big long long
const long double eps = 1e-12;
const long long inf = 1LL << 60;
const long long lim = 1e9;
long long R, sx, sy, sx2, sy2, vx, vy, l, r; big X, Y, Z, T;
bool check(long long a) { // is it in the circle
if (a < 0) return 0;
if (a > lim) return 0;
return (sx + a * vx) * (sx + a * vx) + (sy + a * vy) * (sy + a * vy) <= R * R;
}
pair<long long, long long> p[200008];
vector<long long> tbc;
void compress() {sort(tbc.begin(), tbc.end()); tbc.resize(unique(tbc.begin(), tbc.end()) - tbc.begin());}
int order(long long key) {return lower_bound(tbc.begin(), tbc.end(), key) - tbc.begin() + 1;}
int upd[400008];
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int n, ans = 0, m = 0; cin >> n >> R;
pair<long long, long long> range;
for (int i = 1; i <= n; ++i) {
cin >> sx >> sy >> sx2 >> sy2; vx = sx2 - sx; vy = sy2 - sy;
X = vx * vx + vy * vy; Y = 2 * (sx * vx + sy * vy);
Z = R * R - sx * sx - sy * sy; T = 4 * X * Z + Y * Y;
if (T < 0) continue;
l = (-Y - sqrtl(T)) / (2 * X); r = (-Y + sqrtl(T)) / (2 * X);
l = max(l, 0LL); r = max(r, 0LL);
range = {1, -1};
for (long long i = l - 10; i <= l + 10; ++i) if (check(i)) {range.first = i; break;}
for (long long i = r + 10; i >= r - 10; --i) if (check(i)) {range.second = i; break;}
// for (int j = 0; j <= 20000; ++j) if (check(l)) {range.first = j; break;}
// for (int j = 20000; j >= 0; --j) if (check(r)) {range.second = j; break;}
// cout << i << ' ' << range.first << ' ' << range.second << '\n';
// cout << X << ' ' << Y << ' ' << Z << ' ' << T << ' ' << l << ' ' << r << '\n';
if (range.first <= range.second) {
p[++m] = range;
tbc.push_back(range.first); tbc.push_back(range.second);
}
}
compress();
for (int i = 1; i <= m; ++i) p[i].first = order(p[i].first), p[i].second = order(p[i].second);
for (int i = 1; i <= m; ++i) ++upd[p[i].first], --upd[p[i].second + 1];
for (int i = 1; i <= tbc.size() + 1; ++i) upd[i] += upd[i - 1];
ans += *max_element(upd + 1, upd + tbc.size() + 1);
cout << ans;
}
Compilation message
noras.cpp: In function 'int main()':
noras.cpp:53:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | for (int i = 1; i <= tbc.size() + 1; ++i) upd[i] += upd[i - 1];
| ~~^~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
476 KB |
Output is correct |
7 |
Correct |
1 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
476 KB |
Output is correct |
7 |
Correct |
1 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
27 ms |
3904 KB |
Output is correct |
24 |
Correct |
27 ms |
5068 KB |
Output is correct |
25 |
Correct |
25 ms |
6560 KB |
Output is correct |
26 |
Correct |
28 ms |
5112 KB |
Output is correct |
27 |
Correct |
32 ms |
3920 KB |
Output is correct |
28 |
Correct |
30 ms |
5068 KB |
Output is correct |
29 |
Correct |
30 ms |
5076 KB |
Output is correct |
30 |
Correct |
30 ms |
5076 KB |
Output is correct |
31 |
Correct |
31 ms |
5100 KB |
Output is correct |
32 |
Correct |
44 ms |
5328 KB |
Output is correct |
33 |
Correct |
52 ms |
5316 KB |
Output is correct |
34 |
Correct |
44 ms |
5320 KB |
Output is correct |
35 |
Correct |
42 ms |
6612 KB |
Output is correct |
36 |
Correct |
43 ms |
6676 KB |
Output is correct |
37 |
Correct |
27 ms |
4044 KB |
Output is correct |
38 |
Correct |
27 ms |
4056 KB |
Output is correct |
39 |
Correct |
26 ms |
5084 KB |
Output is correct |
40 |
Correct |
26 ms |
5072 KB |
Output is correct |
41 |
Correct |
29 ms |
6872 KB |
Output is correct |
42 |
Correct |
31 ms |
5072 KB |
Output is correct |
43 |
Correct |
94 ms |
12488 KB |
Output is correct |
44 |
Correct |
89 ms |
12480 KB |
Output is correct |
45 |
Correct |
104 ms |
12480 KB |
Output is correct |
46 |
Correct |
88 ms |
12480 KB |
Output is correct |
47 |
Correct |
96 ms |
12488 KB |
Output is correct |
48 |
Correct |
86 ms |
11460 KB |
Output is correct |
49 |
Correct |
90 ms |
11472 KB |
Output is correct |
50 |
Correct |
86 ms |
11268 KB |
Output is correct |
51 |
Correct |
80 ms |
9924 KB |
Output is correct |
52 |
Correct |
96 ms |
11204 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
476 KB |
Output is correct |
7 |
Correct |
1 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
1 ms |
600 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
2396 KB |
Output is correct |
26 |
Correct |
1 ms |
348 KB |
Output is correct |
27 |
Correct |
1 ms |
348 KB |
Output is correct |
28 |
Correct |
1 ms |
2396 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
476 KB |
Output is correct |
7 |
Correct |
1 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
27 ms |
3904 KB |
Output is correct |
24 |
Correct |
27 ms |
5068 KB |
Output is correct |
25 |
Correct |
25 ms |
6560 KB |
Output is correct |
26 |
Correct |
28 ms |
5112 KB |
Output is correct |
27 |
Correct |
32 ms |
3920 KB |
Output is correct |
28 |
Correct |
30 ms |
5068 KB |
Output is correct |
29 |
Correct |
30 ms |
5076 KB |
Output is correct |
30 |
Correct |
30 ms |
5076 KB |
Output is correct |
31 |
Correct |
31 ms |
5100 KB |
Output is correct |
32 |
Correct |
44 ms |
5328 KB |
Output is correct |
33 |
Correct |
52 ms |
5316 KB |
Output is correct |
34 |
Correct |
44 ms |
5320 KB |
Output is correct |
35 |
Correct |
42 ms |
6612 KB |
Output is correct |
36 |
Correct |
43 ms |
6676 KB |
Output is correct |
37 |
Correct |
27 ms |
4044 KB |
Output is correct |
38 |
Correct |
27 ms |
4056 KB |
Output is correct |
39 |
Correct |
26 ms |
5084 KB |
Output is correct |
40 |
Correct |
26 ms |
5072 KB |
Output is correct |
41 |
Correct |
29 ms |
6872 KB |
Output is correct |
42 |
Correct |
31 ms |
5072 KB |
Output is correct |
43 |
Correct |
94 ms |
12488 KB |
Output is correct |
44 |
Correct |
89 ms |
12480 KB |
Output is correct |
45 |
Correct |
104 ms |
12480 KB |
Output is correct |
46 |
Correct |
88 ms |
12480 KB |
Output is correct |
47 |
Correct |
96 ms |
12488 KB |
Output is correct |
48 |
Correct |
86 ms |
11460 KB |
Output is correct |
49 |
Correct |
90 ms |
11472 KB |
Output is correct |
50 |
Correct |
86 ms |
11268 KB |
Output is correct |
51 |
Correct |
80 ms |
9924 KB |
Output is correct |
52 |
Correct |
96 ms |
11204 KB |
Output is correct |
53 |
Correct |
1 ms |
600 KB |
Output is correct |
54 |
Correct |
1 ms |
348 KB |
Output is correct |
55 |
Correct |
1 ms |
2396 KB |
Output is correct |
56 |
Correct |
1 ms |
348 KB |
Output is correct |
57 |
Correct |
1 ms |
348 KB |
Output is correct |
58 |
Correct |
1 ms |
2396 KB |
Output is correct |
59 |
Correct |
29 ms |
4904 KB |
Output is correct |
60 |
Correct |
28 ms |
4088 KB |
Output is correct |
61 |
Correct |
30 ms |
4044 KB |
Output is correct |
62 |
Correct |
31 ms |
4152 KB |
Output is correct |
63 |
Correct |
37 ms |
4128 KB |
Output is correct |
64 |
Correct |
37 ms |
3800 KB |
Output is correct |
65 |
Correct |
42 ms |
4324 KB |
Output is correct |
66 |
Correct |
41 ms |
4048 KB |
Output is correct |
67 |
Correct |
37 ms |
4044 KB |
Output is correct |
68 |
Correct |
51 ms |
5344 KB |
Output is correct |
69 |
Correct |
46 ms |
5356 KB |
Output is correct |
70 |
Correct |
47 ms |
5320 KB |
Output is correct |
71 |
Correct |
46 ms |
5324 KB |
Output is correct |
72 |
Correct |
48 ms |
5336 KB |
Output is correct |
73 |
Correct |
33 ms |
3936 KB |
Output is correct |
74 |
Correct |
31 ms |
6584 KB |
Output is correct |
75 |
Correct |
30 ms |
5072 KB |
Output is correct |
76 |
Correct |
30 ms |
5336 KB |
Output is correct |
77 |
Correct |
94 ms |
10640 KB |
Output is correct |
78 |
Correct |
98 ms |
11716 KB |
Output is correct |
79 |
Correct |
99 ms |
10480 KB |
Output is correct |
80 |
Correct |
112 ms |
10420 KB |
Output is correct |
81 |
Correct |
95 ms |
10304 KB |
Output is correct |
82 |
Correct |
105 ms |
11620 KB |
Output is correct |
83 |
Correct |
94 ms |
10148 KB |
Output is correct |
84 |
Correct |
86 ms |
10156 KB |
Output is correct |
85 |
Correct |
95 ms |
10176 KB |
Output is correct |
86 |
Correct |
92 ms |
11732 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2396 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
476 KB |
Output is correct |
7 |
Correct |
1 ms |
344 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 |
0 ms |
348 KB |
Output is correct |
14 |
Correct |
0 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
348 KB |
Output is correct |
16 |
Correct |
1 ms |
348 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 |
348 KB |
Output is correct |
21 |
Correct |
1 ms |
2396 KB |
Output is correct |
22 |
Correct |
0 ms |
348 KB |
Output is correct |
23 |
Correct |
27 ms |
3904 KB |
Output is correct |
24 |
Correct |
27 ms |
5068 KB |
Output is correct |
25 |
Correct |
25 ms |
6560 KB |
Output is correct |
26 |
Correct |
28 ms |
5112 KB |
Output is correct |
27 |
Correct |
32 ms |
3920 KB |
Output is correct |
28 |
Correct |
30 ms |
5068 KB |
Output is correct |
29 |
Correct |
30 ms |
5076 KB |
Output is correct |
30 |
Correct |
30 ms |
5076 KB |
Output is correct |
31 |
Correct |
31 ms |
5100 KB |
Output is correct |
32 |
Correct |
44 ms |
5328 KB |
Output is correct |
33 |
Correct |
52 ms |
5316 KB |
Output is correct |
34 |
Correct |
44 ms |
5320 KB |
Output is correct |
35 |
Correct |
42 ms |
6612 KB |
Output is correct |
36 |
Correct |
43 ms |
6676 KB |
Output is correct |
37 |
Correct |
27 ms |
4044 KB |
Output is correct |
38 |
Correct |
27 ms |
4056 KB |
Output is correct |
39 |
Correct |
26 ms |
5084 KB |
Output is correct |
40 |
Correct |
26 ms |
5072 KB |
Output is correct |
41 |
Correct |
29 ms |
6872 KB |
Output is correct |
42 |
Correct |
31 ms |
5072 KB |
Output is correct |
43 |
Correct |
94 ms |
12488 KB |
Output is correct |
44 |
Correct |
89 ms |
12480 KB |
Output is correct |
45 |
Correct |
104 ms |
12480 KB |
Output is correct |
46 |
Correct |
88 ms |
12480 KB |
Output is correct |
47 |
Correct |
96 ms |
12488 KB |
Output is correct |
48 |
Correct |
86 ms |
11460 KB |
Output is correct |
49 |
Correct |
90 ms |
11472 KB |
Output is correct |
50 |
Correct |
86 ms |
11268 KB |
Output is correct |
51 |
Correct |
80 ms |
9924 KB |
Output is correct |
52 |
Correct |
96 ms |
11204 KB |
Output is correct |
53 |
Correct |
29 ms |
4904 KB |
Output is correct |
54 |
Correct |
28 ms |
4088 KB |
Output is correct |
55 |
Correct |
30 ms |
4044 KB |
Output is correct |
56 |
Correct |
31 ms |
4152 KB |
Output is correct |
57 |
Correct |
37 ms |
4128 KB |
Output is correct |
58 |
Correct |
37 ms |
3800 KB |
Output is correct |
59 |
Correct |
42 ms |
4324 KB |
Output is correct |
60 |
Correct |
41 ms |
4048 KB |
Output is correct |
61 |
Correct |
37 ms |
4044 KB |
Output is correct |
62 |
Correct |
51 ms |
5344 KB |
Output is correct |
63 |
Correct |
46 ms |
5356 KB |
Output is correct |
64 |
Correct |
47 ms |
5320 KB |
Output is correct |
65 |
Correct |
46 ms |
5324 KB |
Output is correct |
66 |
Correct |
48 ms |
5336 KB |
Output is correct |
67 |
Correct |
33 ms |
3936 KB |
Output is correct |
68 |
Correct |
31 ms |
6584 KB |
Output is correct |
69 |
Correct |
30 ms |
5072 KB |
Output is correct |
70 |
Correct |
30 ms |
5336 KB |
Output is correct |
71 |
Correct |
94 ms |
10640 KB |
Output is correct |
72 |
Correct |
98 ms |
11716 KB |
Output is correct |
73 |
Correct |
99 ms |
10480 KB |
Output is correct |
74 |
Correct |
112 ms |
10420 KB |
Output is correct |
75 |
Correct |
95 ms |
10304 KB |
Output is correct |
76 |
Correct |
105 ms |
11620 KB |
Output is correct |
77 |
Correct |
94 ms |
10148 KB |
Output is correct |
78 |
Correct |
86 ms |
10156 KB |
Output is correct |
79 |
Correct |
95 ms |
10176 KB |
Output is correct |
80 |
Correct |
92 ms |
11732 KB |
Output is correct |
81 |
Correct |
1 ms |
600 KB |
Output is correct |
82 |
Correct |
1 ms |
348 KB |
Output is correct |
83 |
Correct |
1 ms |
2396 KB |
Output is correct |
84 |
Correct |
1 ms |
348 KB |
Output is correct |
85 |
Correct |
1 ms |
348 KB |
Output is correct |
86 |
Correct |
1 ms |
2396 KB |
Output is correct |
87 |
Correct |
62 ms |
7116 KB |
Output is correct |
88 |
Correct |
47 ms |
5836 KB |
Output is correct |
89 |
Correct |
48 ms |
5612 KB |
Output is correct |
90 |
Correct |
53 ms |
5584 KB |
Output is correct |
91 |
Correct |
48 ms |
8916 KB |
Output is correct |
92 |
Correct |
55 ms |
5836 KB |
Output is correct |
93 |
Correct |
51 ms |
5840 KB |
Output is correct |
94 |
Correct |
55 ms |
5992 KB |
Output is correct |
95 |
Correct |
49 ms |
5840 KB |
Output is correct |
96 |
Correct |
49 ms |
5836 KB |
Output is correct |
97 |
Correct |
38 ms |
5844 KB |
Output is correct |
98 |
Correct |
33 ms |
5924 KB |
Output is correct |
99 |
Correct |
35 ms |
5908 KB |
Output is correct |
100 |
Correct |
33 ms |
5960 KB |
Output is correct |
101 |
Correct |
32 ms |
5844 KB |
Output is correct |
102 |
Correct |
45 ms |
5836 KB |
Output is correct |
103 |
Correct |
33 ms |
5836 KB |
Output is correct |
104 |
Correct |
33 ms |
5828 KB |
Output is correct |
105 |
Correct |
34 ms |
5828 KB |
Output is correct |
106 |
Correct |
34 ms |
5844 KB |
Output is correct |