# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
716118 |
2023-03-29T04:10:45 Z |
tengiz05 |
Wish (LMIO19_noras) |
C++17 |
|
181 ms |
12264 KB |
#include <bits/stdc++.h>
using i64 = long long;
struct Vector {
i64 x, y;
Vector(i64 x = 0, i64 y = 0) : x(x), y(y) {}
Vector operator-(Vector b) {
return Vector(x - b.x, y - b.y);
}
Vector operator+(Vector b) {
return Vector(x + b.x, y + b.y);
}
Vector operator*(i64 k) {
return Vector(x * k, y * k);
}
__int128 length() {
return __int128(x) * x + __int128(y) * y;
}
};
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
int n;
i64 Rin;
std::cin >> n >> Rin;
__int128 R = __int128(Rin) * Rin;
std::vector<Vector> a(n), b(n);
for (int i = 0; i < n; i++) {
std::cin >> a[i].x >> a[i].y >> b[i].x >> b[i].y;
}
std::vector<std::pair<int, int>> v;
for (int i = 0; i < n; i++) {
Vector cur = a[i];
Vector delta = b[i] - a[i];
int lo = 0, hi = 1E9;
while (lo < hi) {
int m = (lo + hi + 1) / 2;
if (cur.length() >= (delta * m).length() && cur.length() >= (cur + delta * m).length()) {
lo = m;
} else {
hi = m - 1;
}
}
int p = std::max(0, lo - 40);
while (p < lo + 80 && (cur + delta * p).length() > R) p++;
if ((cur + delta * p).length() > R) continue;
//~ int l = -1, r = -1;
//~ cur = a[i];
//~ delta = b[i] - a[i];
//~ for (int j = 0; j < 20005; j++) {
//~ if (cur.length() <= R) {
//~ if (l == -1) {
//~ l = j;
//~ }
//~ r = j;
//~ }
//~ cur = cur + delta;
//~ }
//~ assert(l != -1);
//~ std::cerr << l << " " << r << "\n";
//~ v.push_back({l, r});
cur = cur + delta * p;
lo = 0, hi = 1E9;
while (lo < hi) {
int m = (lo + hi + 1) / 2;
if ((cur - delta * m).length() <= R) {
lo = m;
} else {
hi = m - 1;
}
}
int l = std::max(0, p - lo);
lo = 0, hi = 1E9;
while (lo < hi) {
int m = (lo + hi + 1) / 2;
if ((cur + delta * m).length() <= R) {
lo = m;
} else {
hi = m - 1;
}
}
int r = p + lo;
v.push_back({l, r});
}
std::vector<std::pair<int, int>> events;
for (auto [l, r] : v) {
events.emplace_back(l, 1);
events.emplace_back(r + 1, -1);
}
std::sort(events.begin(), events.end());
int k = events.size();
int cnt = 0;
int ans = 0;
for (int i = 0; i < k; ) {
int j = i;
while (j < k && events[i].first == events[j].first)
j++;
while (i < j) {
cnt += events[i].second;
i++;
}
ans = std::max(ans, cnt);
}
std::cout << ans << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 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 |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 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 |
61 ms |
6380 KB |
Output is correct |
24 |
Correct |
56 ms |
6384 KB |
Output is correct |
25 |
Correct |
76 ms |
6368 KB |
Output is correct |
26 |
Correct |
65 ms |
6276 KB |
Output is correct |
27 |
Correct |
57 ms |
4908 KB |
Output is correct |
28 |
Correct |
56 ms |
6220 KB |
Output is correct |
29 |
Correct |
57 ms |
6224 KB |
Output is correct |
30 |
Correct |
58 ms |
6240 KB |
Output is correct |
31 |
Correct |
58 ms |
6224 KB |
Output is correct |
32 |
Correct |
105 ms |
6348 KB |
Output is correct |
33 |
Correct |
76 ms |
6348 KB |
Output is correct |
34 |
Correct |
79 ms |
6352 KB |
Output is correct |
35 |
Correct |
76 ms |
6272 KB |
Output is correct |
36 |
Correct |
75 ms |
6384 KB |
Output is correct |
37 |
Correct |
84 ms |
5112 KB |
Output is correct |
38 |
Correct |
85 ms |
5080 KB |
Output is correct |
39 |
Correct |
65 ms |
5040 KB |
Output is correct |
40 |
Correct |
63 ms |
4976 KB |
Output is correct |
41 |
Correct |
62 ms |
4980 KB |
Output is correct |
42 |
Correct |
64 ms |
4992 KB |
Output is correct |
43 |
Incorrect |
181 ms |
12264 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 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 |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
1 ms |
340 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 |
340 KB |
Output is correct |
28 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 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 |
61 ms |
6380 KB |
Output is correct |
24 |
Correct |
56 ms |
6384 KB |
Output is correct |
25 |
Correct |
76 ms |
6368 KB |
Output is correct |
26 |
Correct |
65 ms |
6276 KB |
Output is correct |
27 |
Correct |
57 ms |
4908 KB |
Output is correct |
28 |
Correct |
56 ms |
6220 KB |
Output is correct |
29 |
Correct |
57 ms |
6224 KB |
Output is correct |
30 |
Correct |
58 ms |
6240 KB |
Output is correct |
31 |
Correct |
58 ms |
6224 KB |
Output is correct |
32 |
Correct |
105 ms |
6348 KB |
Output is correct |
33 |
Correct |
76 ms |
6348 KB |
Output is correct |
34 |
Correct |
79 ms |
6352 KB |
Output is correct |
35 |
Correct |
76 ms |
6272 KB |
Output is correct |
36 |
Correct |
75 ms |
6384 KB |
Output is correct |
37 |
Correct |
84 ms |
5112 KB |
Output is correct |
38 |
Correct |
85 ms |
5080 KB |
Output is correct |
39 |
Correct |
65 ms |
5040 KB |
Output is correct |
40 |
Correct |
63 ms |
4976 KB |
Output is correct |
41 |
Correct |
62 ms |
4980 KB |
Output is correct |
42 |
Correct |
64 ms |
4992 KB |
Output is correct |
43 |
Incorrect |
181 ms |
12264 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
2 ms |
340 KB |
Output is correct |
4 |
Correct |
2 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 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 |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
1 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
340 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 |
61 ms |
6380 KB |
Output is correct |
24 |
Correct |
56 ms |
6384 KB |
Output is correct |
25 |
Correct |
76 ms |
6368 KB |
Output is correct |
26 |
Correct |
65 ms |
6276 KB |
Output is correct |
27 |
Correct |
57 ms |
4908 KB |
Output is correct |
28 |
Correct |
56 ms |
6220 KB |
Output is correct |
29 |
Correct |
57 ms |
6224 KB |
Output is correct |
30 |
Correct |
58 ms |
6240 KB |
Output is correct |
31 |
Correct |
58 ms |
6224 KB |
Output is correct |
32 |
Correct |
105 ms |
6348 KB |
Output is correct |
33 |
Correct |
76 ms |
6348 KB |
Output is correct |
34 |
Correct |
79 ms |
6352 KB |
Output is correct |
35 |
Correct |
76 ms |
6272 KB |
Output is correct |
36 |
Correct |
75 ms |
6384 KB |
Output is correct |
37 |
Correct |
84 ms |
5112 KB |
Output is correct |
38 |
Correct |
85 ms |
5080 KB |
Output is correct |
39 |
Correct |
65 ms |
5040 KB |
Output is correct |
40 |
Correct |
63 ms |
4976 KB |
Output is correct |
41 |
Correct |
62 ms |
4980 KB |
Output is correct |
42 |
Correct |
64 ms |
4992 KB |
Output is correct |
43 |
Incorrect |
181 ms |
12264 KB |
Output isn't correct |
44 |
Halted |
0 ms |
0 KB |
- |