Submission #895938

# Submission time Handle Problem Language Result Execution time Memory
895938 2023-12-31T07:27:56 Z omsincoconut Wish (LMIO19_noras) C++17
100 / 100
225 ms 41920 KB
#include <bits/stdc++.h>

using namespace std;

typedef long long int lli;
typedef long double ld;
typedef pair<ld, ld> pld;
#define mp(x, y) make_pair(x, y)

const lli MAXN = 2e5+5;

lli N;
ld R;
pld ab[MAXN], cd[MAXN], vel[MAXN];

vector<pair<ld, lli>> events;

inline pld operator + (pld inp1, pld inp2) {
    return mp(inp1.first + inp2.first, inp1.second + inp2.second);
}

inline pld operator - (pld inp1, pld inp2) {
    return mp(inp1.first - inp2.first, inp1.second - inp2.second);
}

inline pld operator * (pld inp1, pld inp2) {
    return mp(inp1.first * inp2.first, inp1.second * inp2.second);
}

inline pld operator / (pld inp1, pld inp2) {
    return mp(inp1.first / inp2.first, inp1.second / inp2.second);
}

inline pld operator * (pld inp1, ld inp2) {
    return mp(inp1.first * inp2, inp1.second * inp2);
}

inline pld operator * (ld inp1, pld inp2) {
    return inp2*inp1;
}

inline pld operator / (pld inp1, ld inp2) {
    return mp(inp1.first / inp2, inp1.second / inp2);
}

inline pld operator / (ld inp1, pld inp2) {
    return inp2/inp1;
}

inline ld dist(pld inp) {
    return inp.first*inp.first + inp.second*inp.second;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> N >> R;
    for (lli i = 0; i < N; i++) cin >> ab[i].first >> ab[i].second >> cd[i].first >> cd[i].second;
    for (lli i = 0; i < N; i++) vel[i] = cd[i] - ab[i];

    for (lli i = 0; i < N; i++) {
        ld discrim = (2*ab[i].first*vel[i].first + 2*ab[i].second*vel[i].second)*(2*ab[i].first*vel[i].first + 2*ab[i].second*vel[i].second) - 4*dist(vel[i])*(dist(ab[i])-R*R);
        if (discrim < 0) continue;
        ld lessroot = ((2*ab[i].first*vel[i].first + 2*ab[i].second*vel[i].second)-sqrtl(discrim))/(2*dist(vel[i]));
        ld moreroot = ((2*ab[i].first*vel[i].first + 2*ab[i].second*vel[i].second)+sqrtl(discrim))/(2*dist(vel[i]));
        lessroot *= -1;
        moreroot *= -1;
        swap(lessroot, moreroot);
        //cout << i << " " << lessroot << " " << moreroot << "\n";
        if (moreroot < 0) continue;
        events.emplace_back(lessroot-(1e-10), 1);
        events.emplace_back(moreroot+(1e-10), -1);
    }
    sort(events.begin(), events.end());

    lli ans = 0;
    lli ct = 0;
    lli time = 0;
    for (lli i = 0; i < events.size(); i++) {
        time = floor(events[i].first);
        ct += events[i].second;
        while (i+1 < events.size() && time == floor(events[i+1].first)) {
            ct += events[i+1].second;
            i++;
        }
        ans = max(ans, ct);
    }
    cout << ans;
    return 0;
}

Compilation message

noras.cpp: In function 'int main()':
noras.cpp:80:23: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::vector<std::pair<long double, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   80 |     for (lli i = 0; i < events.size(); i++) {
      |                     ~~^~~~~~~~~~~~~~~
noras.cpp:83:20: warning: comparison of integer expressions of different signedness: 'lli' {aka 'long long int'} and 'std::vector<std::pair<long double, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   83 |         while (i+1 < events.size() && time == floor(events[i+1].first)) {
      |                ~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4828 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 1 ms 4564 KB Output is correct
9 Correct 1 ms 4540 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4560 KB Output is correct
14 Correct 2 ms 4592 KB Output is correct
15 Correct 2 ms 4700 KB Output is correct
16 Correct 2 ms 4696 KB Output is correct
17 Correct 2 ms 4596 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 2 ms 4700 KB Output is correct
20 Correct 2 ms 4700 KB Output is correct
21 Correct 2 ms 4760 KB Output is correct
22 Correct 2 ms 4952 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4828 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 1 ms 4564 KB Output is correct
9 Correct 1 ms 4540 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4560 KB Output is correct
14 Correct 2 ms 4592 KB Output is correct
15 Correct 2 ms 4700 KB Output is correct
16 Correct 2 ms 4696 KB Output is correct
17 Correct 2 ms 4596 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 2 ms 4700 KB Output is correct
20 Correct 2 ms 4700 KB Output is correct
21 Correct 2 ms 4760 KB Output is correct
22 Correct 2 ms 4952 KB Output is correct
23 Correct 86 ms 24900 KB Output is correct
24 Correct 87 ms 24884 KB Output is correct
25 Correct 84 ms 25420 KB Output is correct
26 Correct 82 ms 26312 KB Output is correct
27 Correct 87 ms 26512 KB Output is correct
28 Correct 88 ms 25152 KB Output is correct
29 Correct 89 ms 26056 KB Output is correct
30 Correct 93 ms 26172 KB Output is correct
31 Correct 86 ms 26560 KB Output is correct
32 Correct 100 ms 26304 KB Output is correct
33 Correct 106 ms 25276 KB Output is correct
34 Correct 103 ms 26068 KB Output is correct
35 Correct 99 ms 26432 KB Output is correct
36 Correct 98 ms 26692 KB Output is correct
37 Correct 87 ms 26564 KB Output is correct
38 Correct 95 ms 25696 KB Output is correct
39 Correct 88 ms 26040 KB Output is correct
40 Correct 86 ms 25032 KB Output is correct
41 Correct 87 ms 26312 KB Output is correct
42 Correct 94 ms 25540 KB Output is correct
43 Correct 203 ms 40908 KB Output is correct
44 Correct 221 ms 41920 KB Output is correct
45 Correct 199 ms 40128 KB Output is correct
46 Correct 201 ms 41908 KB Output is correct
47 Correct 213 ms 41664 KB Output is correct
48 Correct 195 ms 40644 KB Output is correct
49 Correct 198 ms 39880 KB Output is correct
50 Correct 202 ms 39732 KB Output is correct
51 Correct 193 ms 40392 KB Output is correct
52 Correct 200 ms 40640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4828 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 1 ms 4564 KB Output is correct
9 Correct 1 ms 4540 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4560 KB Output is correct
14 Correct 2 ms 4592 KB Output is correct
15 Correct 2 ms 4700 KB Output is correct
16 Correct 2 ms 4696 KB Output is correct
17 Correct 2 ms 4596 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 2 ms 4700 KB Output is correct
20 Correct 2 ms 4700 KB Output is correct
21 Correct 2 ms 4760 KB Output is correct
22 Correct 2 ms 4952 KB Output is correct
23 Correct 1 ms 4444 KB Output is correct
24 Correct 2 ms 4572 KB Output is correct
25 Correct 2 ms 4952 KB Output is correct
26 Correct 2 ms 4700 KB Output is correct
27 Correct 2 ms 4696 KB Output is correct
28 Correct 2 ms 4700 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4828 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 1 ms 4564 KB Output is correct
9 Correct 1 ms 4540 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4560 KB Output is correct
14 Correct 2 ms 4592 KB Output is correct
15 Correct 2 ms 4700 KB Output is correct
16 Correct 2 ms 4696 KB Output is correct
17 Correct 2 ms 4596 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 2 ms 4700 KB Output is correct
20 Correct 2 ms 4700 KB Output is correct
21 Correct 2 ms 4760 KB Output is correct
22 Correct 2 ms 4952 KB Output is correct
23 Correct 86 ms 24900 KB Output is correct
24 Correct 87 ms 24884 KB Output is correct
25 Correct 84 ms 25420 KB Output is correct
26 Correct 82 ms 26312 KB Output is correct
27 Correct 87 ms 26512 KB Output is correct
28 Correct 88 ms 25152 KB Output is correct
29 Correct 89 ms 26056 KB Output is correct
30 Correct 93 ms 26172 KB Output is correct
31 Correct 86 ms 26560 KB Output is correct
32 Correct 100 ms 26304 KB Output is correct
33 Correct 106 ms 25276 KB Output is correct
34 Correct 103 ms 26068 KB Output is correct
35 Correct 99 ms 26432 KB Output is correct
36 Correct 98 ms 26692 KB Output is correct
37 Correct 87 ms 26564 KB Output is correct
38 Correct 95 ms 25696 KB Output is correct
39 Correct 88 ms 26040 KB Output is correct
40 Correct 86 ms 25032 KB Output is correct
41 Correct 87 ms 26312 KB Output is correct
42 Correct 94 ms 25540 KB Output is correct
43 Correct 203 ms 40908 KB Output is correct
44 Correct 221 ms 41920 KB Output is correct
45 Correct 199 ms 40128 KB Output is correct
46 Correct 201 ms 41908 KB Output is correct
47 Correct 213 ms 41664 KB Output is correct
48 Correct 195 ms 40644 KB Output is correct
49 Correct 198 ms 39880 KB Output is correct
50 Correct 202 ms 39732 KB Output is correct
51 Correct 193 ms 40392 KB Output is correct
52 Correct 200 ms 40640 KB Output is correct
53 Correct 1 ms 4444 KB Output is correct
54 Correct 2 ms 4572 KB Output is correct
55 Correct 2 ms 4952 KB Output is correct
56 Correct 2 ms 4700 KB Output is correct
57 Correct 2 ms 4696 KB Output is correct
58 Correct 2 ms 4700 KB Output is correct
59 Correct 83 ms 26552 KB Output is correct
60 Correct 96 ms 22592 KB Output is correct
61 Correct 85 ms 22216 KB Output is correct
62 Correct 90 ms 25796 KB Output is correct
63 Correct 85 ms 21452 KB Output is correct
64 Correct 84 ms 22088 KB Output is correct
65 Correct 87 ms 23228 KB Output is correct
66 Correct 85 ms 22988 KB Output is correct
67 Correct 84 ms 21956 KB Output is correct
68 Correct 98 ms 26824 KB Output is correct
69 Correct 105 ms 25528 KB Output is correct
70 Correct 98 ms 26680 KB Output is correct
71 Correct 97 ms 26056 KB Output is correct
72 Correct 100 ms 26568 KB Output is correct
73 Correct 97 ms 25292 KB Output is correct
74 Correct 88 ms 25696 KB Output is correct
75 Correct 90 ms 26436 KB Output is correct
76 Correct 90 ms 26684 KB Output is correct
77 Correct 201 ms 40888 KB Output is correct
78 Correct 194 ms 40912 KB Output is correct
79 Correct 196 ms 40896 KB Output is correct
80 Correct 204 ms 41404 KB Output is correct
81 Correct 197 ms 40628 KB Output is correct
82 Correct 198 ms 40900 KB Output is correct
83 Correct 212 ms 39896 KB Output is correct
84 Correct 214 ms 39620 KB Output is correct
85 Correct 198 ms 40756 KB Output is correct
86 Correct 225 ms 41012 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4440 KB Output is correct
2 Correct 1 ms 4828 KB Output is correct
3 Correct 2 ms 4444 KB Output is correct
4 Correct 2 ms 4444 KB Output is correct
5 Correct 2 ms 4444 KB Output is correct
6 Correct 2 ms 4444 KB Output is correct
7 Correct 2 ms 4444 KB Output is correct
8 Correct 1 ms 4564 KB Output is correct
9 Correct 1 ms 4540 KB Output is correct
10 Correct 1 ms 4440 KB Output is correct
11 Correct 1 ms 4440 KB Output is correct
12 Correct 1 ms 4444 KB Output is correct
13 Correct 1 ms 4560 KB Output is correct
14 Correct 2 ms 4592 KB Output is correct
15 Correct 2 ms 4700 KB Output is correct
16 Correct 2 ms 4696 KB Output is correct
17 Correct 2 ms 4596 KB Output is correct
18 Correct 3 ms 4700 KB Output is correct
19 Correct 2 ms 4700 KB Output is correct
20 Correct 2 ms 4700 KB Output is correct
21 Correct 2 ms 4760 KB Output is correct
22 Correct 2 ms 4952 KB Output is correct
23 Correct 86 ms 24900 KB Output is correct
24 Correct 87 ms 24884 KB Output is correct
25 Correct 84 ms 25420 KB Output is correct
26 Correct 82 ms 26312 KB Output is correct
27 Correct 87 ms 26512 KB Output is correct
28 Correct 88 ms 25152 KB Output is correct
29 Correct 89 ms 26056 KB Output is correct
30 Correct 93 ms 26172 KB Output is correct
31 Correct 86 ms 26560 KB Output is correct
32 Correct 100 ms 26304 KB Output is correct
33 Correct 106 ms 25276 KB Output is correct
34 Correct 103 ms 26068 KB Output is correct
35 Correct 99 ms 26432 KB Output is correct
36 Correct 98 ms 26692 KB Output is correct
37 Correct 87 ms 26564 KB Output is correct
38 Correct 95 ms 25696 KB Output is correct
39 Correct 88 ms 26040 KB Output is correct
40 Correct 86 ms 25032 KB Output is correct
41 Correct 87 ms 26312 KB Output is correct
42 Correct 94 ms 25540 KB Output is correct
43 Correct 203 ms 40908 KB Output is correct
44 Correct 221 ms 41920 KB Output is correct
45 Correct 199 ms 40128 KB Output is correct
46 Correct 201 ms 41908 KB Output is correct
47 Correct 213 ms 41664 KB Output is correct
48 Correct 195 ms 40644 KB Output is correct
49 Correct 198 ms 39880 KB Output is correct
50 Correct 202 ms 39732 KB Output is correct
51 Correct 193 ms 40392 KB Output is correct
52 Correct 200 ms 40640 KB Output is correct
53 Correct 83 ms 26552 KB Output is correct
54 Correct 96 ms 22592 KB Output is correct
55 Correct 85 ms 22216 KB Output is correct
56 Correct 90 ms 25796 KB Output is correct
57 Correct 85 ms 21452 KB Output is correct
58 Correct 84 ms 22088 KB Output is correct
59 Correct 87 ms 23228 KB Output is correct
60 Correct 85 ms 22988 KB Output is correct
61 Correct 84 ms 21956 KB Output is correct
62 Correct 98 ms 26824 KB Output is correct
63 Correct 105 ms 25528 KB Output is correct
64 Correct 98 ms 26680 KB Output is correct
65 Correct 97 ms 26056 KB Output is correct
66 Correct 100 ms 26568 KB Output is correct
67 Correct 97 ms 25292 KB Output is correct
68 Correct 88 ms 25696 KB Output is correct
69 Correct 90 ms 26436 KB Output is correct
70 Correct 90 ms 26684 KB Output is correct
71 Correct 201 ms 40888 KB Output is correct
72 Correct 194 ms 40912 KB Output is correct
73 Correct 196 ms 40896 KB Output is correct
74 Correct 204 ms 41404 KB Output is correct
75 Correct 197 ms 40628 KB Output is correct
76 Correct 198 ms 40900 KB Output is correct
77 Correct 212 ms 39896 KB Output is correct
78 Correct 214 ms 39620 KB Output is correct
79 Correct 198 ms 40756 KB Output is correct
80 Correct 225 ms 41012 KB Output is correct
81 Correct 1 ms 4444 KB Output is correct
82 Correct 2 ms 4572 KB Output is correct
83 Correct 2 ms 4952 KB Output is correct
84 Correct 2 ms 4700 KB Output is correct
85 Correct 2 ms 4696 KB Output is correct
86 Correct 2 ms 4700 KB Output is correct
87 Correct 109 ms 22724 KB Output is correct
88 Correct 111 ms 24652 KB Output is correct
89 Correct 112 ms 24520 KB Output is correct
90 Correct 99 ms 23996 KB Output is correct
91 Correct 98 ms 23752 KB Output is correct
92 Correct 112 ms 23496 KB Output is correct
93 Correct 114 ms 23492 KB Output is correct
94 Correct 106 ms 23488 KB Output is correct
95 Correct 104 ms 22848 KB Output is correct
96 Correct 104 ms 23116 KB Output is correct
97 Correct 91 ms 26052 KB Output is correct
98 Correct 89 ms 26972 KB Output is correct
99 Correct 92 ms 25796 KB Output is correct
100 Correct 92 ms 27312 KB Output is correct
101 Correct 91 ms 27592 KB Output is correct
102 Correct 99 ms 26168 KB Output is correct
103 Correct 90 ms 27080 KB Output is correct
104 Correct 98 ms 25540 KB Output is correct
105 Correct 92 ms 27588 KB Output is correct
106 Correct 91 ms 27328 KB Output is correct