Submission #716121

# Submission time Handle Problem Language Result Execution time Memory
716121 2023-03-29T04:20:54 Z tengiz05 Wish (LMIO19_noras) C++17
100 / 100
209 ms 12424 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 + 3 < hi) {
            int m = (lo + hi + 1) / 2;
            if ((cur + delta * m).length() > (cur + delta * (m + 1)).length()) {
                lo = m;
            } else {
                hi = m - 1;
            }
        }
        int p = std::max(0, lo - 4);
        while (p < lo + 4 && (cur + delta * p).length() > R) p++;
        if ((cur + delta * p).length() > R) continue;
        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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 1 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 2 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 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 1 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 2 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 6276 KB Output is correct
24 Correct 60 ms 6340 KB Output is correct
25 Correct 64 ms 6384 KB Output is correct
26 Correct 60 ms 6348 KB Output is correct
27 Correct 53 ms 4992 KB Output is correct
28 Correct 63 ms 6280 KB Output is correct
29 Correct 60 ms 6268 KB Output is correct
30 Correct 58 ms 6276 KB Output is correct
31 Correct 61 ms 6220 KB Output is correct
32 Correct 82 ms 6272 KB Output is correct
33 Correct 78 ms 6392 KB Output is correct
34 Correct 83 ms 6268 KB Output is correct
35 Correct 84 ms 6288 KB Output is correct
36 Correct 81 ms 6360 KB Output is correct
37 Correct 61 ms 5104 KB Output is correct
38 Correct 59 ms 4996 KB Output is correct
39 Correct 57 ms 4944 KB Output is correct
40 Correct 56 ms 4972 KB Output is correct
41 Correct 54 ms 5008 KB Output is correct
42 Correct 56 ms 5004 KB Output is correct
43 Correct 189 ms 12312 KB Output is correct
44 Correct 195 ms 12312 KB Output is correct
45 Correct 180 ms 12336 KB Output is correct
46 Correct 191 ms 12424 KB Output is correct
47 Correct 201 ms 12300 KB Output is correct
48 Correct 166 ms 12232 KB Output is correct
49 Correct 163 ms 12336 KB Output is correct
50 Correct 209 ms 12332 KB Output is correct
51 Correct 166 ms 12348 KB Output is correct
52 Correct 164 ms 12216 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 1 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 2 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 2 ms 340 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 340 KB Output is correct
28 Correct 2 ms 340 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 1 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 2 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 6276 KB Output is correct
24 Correct 60 ms 6340 KB Output is correct
25 Correct 64 ms 6384 KB Output is correct
26 Correct 60 ms 6348 KB Output is correct
27 Correct 53 ms 4992 KB Output is correct
28 Correct 63 ms 6280 KB Output is correct
29 Correct 60 ms 6268 KB Output is correct
30 Correct 58 ms 6276 KB Output is correct
31 Correct 61 ms 6220 KB Output is correct
32 Correct 82 ms 6272 KB Output is correct
33 Correct 78 ms 6392 KB Output is correct
34 Correct 83 ms 6268 KB Output is correct
35 Correct 84 ms 6288 KB Output is correct
36 Correct 81 ms 6360 KB Output is correct
37 Correct 61 ms 5104 KB Output is correct
38 Correct 59 ms 4996 KB Output is correct
39 Correct 57 ms 4944 KB Output is correct
40 Correct 56 ms 4972 KB Output is correct
41 Correct 54 ms 5008 KB Output is correct
42 Correct 56 ms 5004 KB Output is correct
43 Correct 189 ms 12312 KB Output is correct
44 Correct 195 ms 12312 KB Output is correct
45 Correct 180 ms 12336 KB Output is correct
46 Correct 191 ms 12424 KB Output is correct
47 Correct 201 ms 12300 KB Output is correct
48 Correct 166 ms 12232 KB Output is correct
49 Correct 163 ms 12336 KB Output is correct
50 Correct 209 ms 12332 KB Output is correct
51 Correct 166 ms 12348 KB Output is correct
52 Correct 164 ms 12216 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 2 ms 340 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 1 ms 340 KB Output is correct
58 Correct 2 ms 340 KB Output is correct
59 Correct 67 ms 6356 KB Output is correct
60 Correct 56 ms 4944 KB Output is correct
61 Correct 56 ms 4976 KB Output is correct
62 Correct 63 ms 5072 KB Output is correct
63 Correct 66 ms 4844 KB Output is correct
64 Correct 64 ms 4824 KB Output is correct
65 Correct 65 ms 4944 KB Output is correct
66 Correct 71 ms 4864 KB Output is correct
67 Correct 65 ms 4856 KB Output is correct
68 Correct 89 ms 6384 KB Output is correct
69 Correct 81 ms 6352 KB Output is correct
70 Correct 84 ms 6392 KB Output is correct
71 Correct 88 ms 6396 KB Output is correct
72 Correct 100 ms 6364 KB Output is correct
73 Correct 62 ms 5032 KB Output is correct
74 Correct 59 ms 6144 KB Output is correct
75 Correct 60 ms 6144 KB Output is correct
76 Correct 69 ms 5004 KB Output is correct
77 Correct 177 ms 12148 KB Output is correct
78 Correct 175 ms 12172 KB Output is correct
79 Correct 178 ms 12176 KB Output is correct
80 Correct 209 ms 12216 KB Output is correct
81 Correct 185 ms 12252 KB Output is correct
82 Correct 171 ms 12256 KB Output is correct
83 Correct 164 ms 12332 KB Output is correct
84 Correct 165 ms 12424 KB Output is correct
85 Correct 166 ms 12232 KB Output is correct
86 Correct 165 ms 12308 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 1 ms 340 KB Output is correct
4 Correct 1 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 1 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 2 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 6276 KB Output is correct
24 Correct 60 ms 6340 KB Output is correct
25 Correct 64 ms 6384 KB Output is correct
26 Correct 60 ms 6348 KB Output is correct
27 Correct 53 ms 4992 KB Output is correct
28 Correct 63 ms 6280 KB Output is correct
29 Correct 60 ms 6268 KB Output is correct
30 Correct 58 ms 6276 KB Output is correct
31 Correct 61 ms 6220 KB Output is correct
32 Correct 82 ms 6272 KB Output is correct
33 Correct 78 ms 6392 KB Output is correct
34 Correct 83 ms 6268 KB Output is correct
35 Correct 84 ms 6288 KB Output is correct
36 Correct 81 ms 6360 KB Output is correct
37 Correct 61 ms 5104 KB Output is correct
38 Correct 59 ms 4996 KB Output is correct
39 Correct 57 ms 4944 KB Output is correct
40 Correct 56 ms 4972 KB Output is correct
41 Correct 54 ms 5008 KB Output is correct
42 Correct 56 ms 5004 KB Output is correct
43 Correct 189 ms 12312 KB Output is correct
44 Correct 195 ms 12312 KB Output is correct
45 Correct 180 ms 12336 KB Output is correct
46 Correct 191 ms 12424 KB Output is correct
47 Correct 201 ms 12300 KB Output is correct
48 Correct 166 ms 12232 KB Output is correct
49 Correct 163 ms 12336 KB Output is correct
50 Correct 209 ms 12332 KB Output is correct
51 Correct 166 ms 12348 KB Output is correct
52 Correct 164 ms 12216 KB Output is correct
53 Correct 67 ms 6356 KB Output is correct
54 Correct 56 ms 4944 KB Output is correct
55 Correct 56 ms 4976 KB Output is correct
56 Correct 63 ms 5072 KB Output is correct
57 Correct 66 ms 4844 KB Output is correct
58 Correct 64 ms 4824 KB Output is correct
59 Correct 65 ms 4944 KB Output is correct
60 Correct 71 ms 4864 KB Output is correct
61 Correct 65 ms 4856 KB Output is correct
62 Correct 89 ms 6384 KB Output is correct
63 Correct 81 ms 6352 KB Output is correct
64 Correct 84 ms 6392 KB Output is correct
65 Correct 88 ms 6396 KB Output is correct
66 Correct 100 ms 6364 KB Output is correct
67 Correct 62 ms 5032 KB Output is correct
68 Correct 59 ms 6144 KB Output is correct
69 Correct 60 ms 6144 KB Output is correct
70 Correct 69 ms 5004 KB Output is correct
71 Correct 177 ms 12148 KB Output is correct
72 Correct 175 ms 12172 KB Output is correct
73 Correct 178 ms 12176 KB Output is correct
74 Correct 209 ms 12216 KB Output is correct
75 Correct 185 ms 12252 KB Output is correct
76 Correct 171 ms 12256 KB Output is correct
77 Correct 164 ms 12332 KB Output is correct
78 Correct 165 ms 12424 KB Output is correct
79 Correct 166 ms 12232 KB Output is correct
80 Correct 165 ms 12308 KB Output is correct
81 Correct 0 ms 212 KB Output is correct
82 Correct 1 ms 340 KB Output is correct
83 Correct 2 ms 340 KB Output is correct
84 Correct 1 ms 340 KB Output is correct
85 Correct 1 ms 340 KB Output is correct
86 Correct 2 ms 340 KB Output is correct
87 Correct 82 ms 4852 KB Output is correct
88 Correct 76 ms 4856 KB Output is correct
89 Correct 77 ms 4844 KB Output is correct
90 Correct 81 ms 4848 KB Output is correct
91 Correct 102 ms 4856 KB Output is correct
92 Correct 82 ms 4836 KB Output is correct
93 Correct 84 ms 4948 KB Output is correct
94 Correct 86 ms 5016 KB Output is correct
95 Correct 92 ms 4928 KB Output is correct
96 Correct 98 ms 4912 KB Output is correct
97 Correct 65 ms 6276 KB Output is correct
98 Correct 63 ms 6272 KB Output is correct
99 Correct 89 ms 6392 KB Output is correct
100 Correct 89 ms 6268 KB Output is correct
101 Correct 73 ms 6276 KB Output is correct
102 Correct 73 ms 6288 KB Output is correct
103 Correct 66 ms 6388 KB Output is correct
104 Correct 70 ms 6384 KB Output is correct
105 Correct 68 ms 6404 KB Output is correct
106 Correct 65 ms 6276 KB Output is correct