# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
253213 |
2020-07-27T12:33:03 Z |
maximath_1 |
Wish (LMIO19_noras) |
C++11 |
|
244 ms |
17112 KB |
/*
* LMIO 2019 Wish
* Check when each star passes through the circle
* Produce the formula, to prevent precision problems
* Do binary search/ternary search as well as
* Floor division and ceiling division described in the code
* Using __int128_t to prevent overflow
* Find maximum number of intervals at a time by using prefix sum
*/
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iostream>
#include <iomanip>
using namespace std;
#define ll __int128_t
#define ld long double
ll floor_division(ll a, ll b){
return a / b - (a % b < 0);
}
ll ceiling_division(ll a, ll b){
return a / b + (a % b > 0);
}
ll ll_sqrt(ll x){
ll lf = 0ll, rg = 1000000000000000000ll, res;
for(ll md; lf <= rg;){
md = (lf + rg) / 2;
if(md == 0){
res = 0ll;
lf = 1ll;
continue;
}
if(md > x / md) rg = md - 1;
else{
res = md;
lf = md + 1;
}
}
return res;
}
int n;
ll r, a, b, c, d;
vector<pair<ll, int> > pref;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
long long tmp;
cin >> n >> tmp; r = (ll)tmp;
for(int i = 1; i <= n; i ++){
cin >> tmp; a = (ll)tmp;
cin >> tmp; b = (ll)tmp;
cin >> tmp; c = (ll)tmp;
cin >> tmp; d = (ll)tmp;
c -= a; d -= b;
ll A = c * c + d * d;
ll B = 2ll * a * c + 2ll * b * d;
ll C = a * a + b * b - r * r;
ll D = B * B - 4ll * A * C;
if(D < 0) continue;
ll sqD = ll_sqrt(D);
ll lf = ceiling_division(- B - sqD, 2ll * A);
ll rg = floor_division(- B + sqD, 2ll * A);
if(lf < 0) lf = 0;
if(lf > rg) continue;
pref.push_back({lf, 1});
pref.push_back({rg + 1ll, -1});
}
if(pref.empty()){
cout << 0 << endl;
return 0;
}
sort(pref.begin(), pref.end());
int cnt = pref[0].second, ans = 0;
ll lst = pref[0].first;
for(int i = 1; i < pref.size(); i ++){
if(lst != pref[i].first){
ans = max(ans, cnt);
lst = pref[i].first;
}
cnt += pref[i].second;
}
ans = max(ans, cnt);
cout << ans << endl;
return 0;
}
Compilation message
noras.cpp: In function 'int main()':
noras.cpp:91:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int i = 1; i < pref.size(); i ++){
~~^~~~~~~~~~~~~
noras.cpp: In function '__int128 ll_sqrt(__int128)':
noras.cpp:44:9: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
return res;
^~~
noras.cpp: In function 'int main()':
noras.cpp:74:25: warning: 'res' may be used uninitialized in this function [-Wmaybe-uninitialized]
ll rg = floor_division(- B + sqD, 2ll * A);
~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
512 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
512 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
97 ms |
8676 KB |
Output is correct |
24 |
Correct |
95 ms |
8672 KB |
Output is correct |
25 |
Correct |
95 ms |
8672 KB |
Output is correct |
26 |
Correct |
102 ms |
8676 KB |
Output is correct |
27 |
Correct |
105 ms |
4588 KB |
Output is correct |
28 |
Correct |
106 ms |
8672 KB |
Output is correct |
29 |
Correct |
105 ms |
8676 KB |
Output is correct |
30 |
Correct |
105 ms |
8672 KB |
Output is correct |
31 |
Correct |
119 ms |
8720 KB |
Output is correct |
32 |
Correct |
111 ms |
8672 KB |
Output is correct |
33 |
Correct |
106 ms |
8672 KB |
Output is correct |
34 |
Correct |
118 ms |
8656 KB |
Output is correct |
35 |
Correct |
114 ms |
8672 KB |
Output is correct |
36 |
Correct |
111 ms |
8672 KB |
Output is correct |
37 |
Correct |
107 ms |
4584 KB |
Output is correct |
38 |
Correct |
91 ms |
4588 KB |
Output is correct |
39 |
Correct |
90 ms |
4588 KB |
Output is correct |
40 |
Correct |
89 ms |
4616 KB |
Output is correct |
41 |
Correct |
88 ms |
4588 KB |
Output is correct |
42 |
Correct |
96 ms |
4584 KB |
Output is correct |
43 |
Correct |
241 ms |
16852 KB |
Output is correct |
44 |
Correct |
240 ms |
16852 KB |
Output is correct |
45 |
Correct |
237 ms |
17112 KB |
Output is correct |
46 |
Correct |
243 ms |
16852 KB |
Output is correct |
47 |
Correct |
235 ms |
16852 KB |
Output is correct |
48 |
Correct |
219 ms |
17056 KB |
Output is correct |
49 |
Correct |
217 ms |
16852 KB |
Output is correct |
50 |
Correct |
224 ms |
16852 KB |
Output is correct |
51 |
Correct |
226 ms |
16880 KB |
Output is correct |
52 |
Correct |
217 ms |
16852 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
512 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
0 ms |
384 KB |
Output is correct |
24 |
Correct |
1 ms |
512 KB |
Output is correct |
25 |
Correct |
2 ms |
512 KB |
Output is correct |
26 |
Correct |
1 ms |
384 KB |
Output is correct |
27 |
Correct |
1 ms |
384 KB |
Output is correct |
28 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
512 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
97 ms |
8676 KB |
Output is correct |
24 |
Correct |
95 ms |
8672 KB |
Output is correct |
25 |
Correct |
95 ms |
8672 KB |
Output is correct |
26 |
Correct |
102 ms |
8676 KB |
Output is correct |
27 |
Correct |
105 ms |
4588 KB |
Output is correct |
28 |
Correct |
106 ms |
8672 KB |
Output is correct |
29 |
Correct |
105 ms |
8676 KB |
Output is correct |
30 |
Correct |
105 ms |
8672 KB |
Output is correct |
31 |
Correct |
119 ms |
8720 KB |
Output is correct |
32 |
Correct |
111 ms |
8672 KB |
Output is correct |
33 |
Correct |
106 ms |
8672 KB |
Output is correct |
34 |
Correct |
118 ms |
8656 KB |
Output is correct |
35 |
Correct |
114 ms |
8672 KB |
Output is correct |
36 |
Correct |
111 ms |
8672 KB |
Output is correct |
37 |
Correct |
107 ms |
4584 KB |
Output is correct |
38 |
Correct |
91 ms |
4588 KB |
Output is correct |
39 |
Correct |
90 ms |
4588 KB |
Output is correct |
40 |
Correct |
89 ms |
4616 KB |
Output is correct |
41 |
Correct |
88 ms |
4588 KB |
Output is correct |
42 |
Correct |
96 ms |
4584 KB |
Output is correct |
43 |
Correct |
241 ms |
16852 KB |
Output is correct |
44 |
Correct |
240 ms |
16852 KB |
Output is correct |
45 |
Correct |
237 ms |
17112 KB |
Output is correct |
46 |
Correct |
243 ms |
16852 KB |
Output is correct |
47 |
Correct |
235 ms |
16852 KB |
Output is correct |
48 |
Correct |
219 ms |
17056 KB |
Output is correct |
49 |
Correct |
217 ms |
16852 KB |
Output is correct |
50 |
Correct |
224 ms |
16852 KB |
Output is correct |
51 |
Correct |
226 ms |
16880 KB |
Output is correct |
52 |
Correct |
217 ms |
16852 KB |
Output is correct |
53 |
Correct |
97 ms |
8672 KB |
Output is correct |
54 |
Correct |
100 ms |
4584 KB |
Output is correct |
55 |
Correct |
108 ms |
4592 KB |
Output is correct |
56 |
Correct |
102 ms |
4588 KB |
Output is correct |
57 |
Correct |
92 ms |
4584 KB |
Output is correct |
58 |
Correct |
95 ms |
4580 KB |
Output is correct |
59 |
Correct |
97 ms |
4588 KB |
Output is correct |
60 |
Correct |
96 ms |
4588 KB |
Output is correct |
61 |
Correct |
101 ms |
4584 KB |
Output is correct |
62 |
Correct |
119 ms |
8716 KB |
Output is correct |
63 |
Correct |
108 ms |
8676 KB |
Output is correct |
64 |
Correct |
112 ms |
8672 KB |
Output is correct |
65 |
Correct |
108 ms |
8632 KB |
Output is correct |
66 |
Correct |
112 ms |
8672 KB |
Output is correct |
67 |
Correct |
95 ms |
4584 KB |
Output is correct |
68 |
Correct |
93 ms |
8672 KB |
Output is correct |
69 |
Correct |
102 ms |
8800 KB |
Output is correct |
70 |
Correct |
91 ms |
4564 KB |
Output is correct |
71 |
Correct |
229 ms |
16852 KB |
Output is correct |
72 |
Correct |
242 ms |
16852 KB |
Output is correct |
73 |
Correct |
242 ms |
16852 KB |
Output is correct |
74 |
Correct |
244 ms |
16852 KB |
Output is correct |
75 |
Correct |
232 ms |
16852 KB |
Output is correct |
76 |
Correct |
229 ms |
16980 KB |
Output is correct |
77 |
Correct |
217 ms |
16980 KB |
Output is correct |
78 |
Correct |
221 ms |
16852 KB |
Output is correct |
79 |
Correct |
224 ms |
17108 KB |
Output is correct |
80 |
Correct |
216 ms |
16852 KB |
Output is correct |
81 |
Correct |
0 ms |
384 KB |
Output is correct |
82 |
Correct |
1 ms |
512 KB |
Output is correct |
83 |
Correct |
2 ms |
512 KB |
Output is correct |
84 |
Correct |
1 ms |
384 KB |
Output is correct |
85 |
Correct |
1 ms |
384 KB |
Output is correct |
86 |
Correct |
2 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
2 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
0 ms |
384 KB |
Output is correct |
9 |
Correct |
0 ms |
384 KB |
Output is correct |
10 |
Correct |
0 ms |
384 KB |
Output is correct |
11 |
Correct |
0 ms |
384 KB |
Output is correct |
12 |
Correct |
0 ms |
384 KB |
Output is correct |
13 |
Correct |
0 ms |
384 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
1 ms |
512 KB |
Output is correct |
16 |
Correct |
1 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
1 ms |
512 KB |
Output is correct |
19 |
Correct |
1 ms |
512 KB |
Output is correct |
20 |
Correct |
1 ms |
384 KB |
Output is correct |
21 |
Correct |
1 ms |
384 KB |
Output is correct |
22 |
Correct |
1 ms |
384 KB |
Output is correct |
23 |
Correct |
97 ms |
8676 KB |
Output is correct |
24 |
Correct |
95 ms |
8672 KB |
Output is correct |
25 |
Correct |
95 ms |
8672 KB |
Output is correct |
26 |
Correct |
102 ms |
8676 KB |
Output is correct |
27 |
Correct |
105 ms |
4588 KB |
Output is correct |
28 |
Correct |
106 ms |
8672 KB |
Output is correct |
29 |
Correct |
105 ms |
8676 KB |
Output is correct |
30 |
Correct |
105 ms |
8672 KB |
Output is correct |
31 |
Correct |
119 ms |
8720 KB |
Output is correct |
32 |
Correct |
111 ms |
8672 KB |
Output is correct |
33 |
Correct |
106 ms |
8672 KB |
Output is correct |
34 |
Correct |
118 ms |
8656 KB |
Output is correct |
35 |
Correct |
114 ms |
8672 KB |
Output is correct |
36 |
Correct |
111 ms |
8672 KB |
Output is correct |
37 |
Correct |
107 ms |
4584 KB |
Output is correct |
38 |
Correct |
91 ms |
4588 KB |
Output is correct |
39 |
Correct |
90 ms |
4588 KB |
Output is correct |
40 |
Correct |
89 ms |
4616 KB |
Output is correct |
41 |
Correct |
88 ms |
4588 KB |
Output is correct |
42 |
Correct |
96 ms |
4584 KB |
Output is correct |
43 |
Correct |
241 ms |
16852 KB |
Output is correct |
44 |
Correct |
240 ms |
16852 KB |
Output is correct |
45 |
Correct |
237 ms |
17112 KB |
Output is correct |
46 |
Correct |
243 ms |
16852 KB |
Output is correct |
47 |
Correct |
235 ms |
16852 KB |
Output is correct |
48 |
Correct |
219 ms |
17056 KB |
Output is correct |
49 |
Correct |
217 ms |
16852 KB |
Output is correct |
50 |
Correct |
224 ms |
16852 KB |
Output is correct |
51 |
Correct |
226 ms |
16880 KB |
Output is correct |
52 |
Correct |
217 ms |
16852 KB |
Output is correct |
53 |
Correct |
97 ms |
8672 KB |
Output is correct |
54 |
Correct |
100 ms |
4584 KB |
Output is correct |
55 |
Correct |
108 ms |
4592 KB |
Output is correct |
56 |
Correct |
102 ms |
4588 KB |
Output is correct |
57 |
Correct |
92 ms |
4584 KB |
Output is correct |
58 |
Correct |
95 ms |
4580 KB |
Output is correct |
59 |
Correct |
97 ms |
4588 KB |
Output is correct |
60 |
Correct |
96 ms |
4588 KB |
Output is correct |
61 |
Correct |
101 ms |
4584 KB |
Output is correct |
62 |
Correct |
119 ms |
8716 KB |
Output is correct |
63 |
Correct |
108 ms |
8676 KB |
Output is correct |
64 |
Correct |
112 ms |
8672 KB |
Output is correct |
65 |
Correct |
108 ms |
8632 KB |
Output is correct |
66 |
Correct |
112 ms |
8672 KB |
Output is correct |
67 |
Correct |
95 ms |
4584 KB |
Output is correct |
68 |
Correct |
93 ms |
8672 KB |
Output is correct |
69 |
Correct |
102 ms |
8800 KB |
Output is correct |
70 |
Correct |
91 ms |
4564 KB |
Output is correct |
71 |
Correct |
229 ms |
16852 KB |
Output is correct |
72 |
Correct |
242 ms |
16852 KB |
Output is correct |
73 |
Correct |
242 ms |
16852 KB |
Output is correct |
74 |
Correct |
244 ms |
16852 KB |
Output is correct |
75 |
Correct |
232 ms |
16852 KB |
Output is correct |
76 |
Correct |
229 ms |
16980 KB |
Output is correct |
77 |
Correct |
217 ms |
16980 KB |
Output is correct |
78 |
Correct |
221 ms |
16852 KB |
Output is correct |
79 |
Correct |
224 ms |
17108 KB |
Output is correct |
80 |
Correct |
216 ms |
16852 KB |
Output is correct |
81 |
Correct |
136 ms |
4580 KB |
Output is correct |
82 |
Correct |
139 ms |
4584 KB |
Output is correct |
83 |
Correct |
141 ms |
4588 KB |
Output is correct |
84 |
Correct |
153 ms |
4716 KB |
Output is correct |
85 |
Correct |
150 ms |
4588 KB |
Output is correct |
86 |
Correct |
131 ms |
4584 KB |
Output is correct |
87 |
Correct |
128 ms |
4588 KB |
Output is correct |
88 |
Correct |
128 ms |
4584 KB |
Output is correct |
89 |
Correct |
127 ms |
4584 KB |
Output is correct |
90 |
Correct |
130 ms |
4584 KB |
Output is correct |
91 |
Correct |
112 ms |
8676 KB |
Output is correct |
92 |
Correct |
113 ms |
8704 KB |
Output is correct |
93 |
Correct |
109 ms |
8676 KB |
Output is correct |
94 |
Correct |
113 ms |
8676 KB |
Output is correct |
95 |
Correct |
113 ms |
8812 KB |
Output is correct |
96 |
Correct |
119 ms |
8672 KB |
Output is correct |
97 |
Correct |
112 ms |
8760 KB |
Output is correct |
98 |
Correct |
113 ms |
8672 KB |
Output is correct |
99 |
Correct |
116 ms |
8820 KB |
Output is correct |
100 |
Correct |
112 ms |
8672 KB |
Output is correct |
101 |
Correct |
0 ms |
384 KB |
Output is correct |
102 |
Correct |
1 ms |
512 KB |
Output is correct |
103 |
Correct |
2 ms |
512 KB |
Output is correct |
104 |
Correct |
1 ms |
384 KB |
Output is correct |
105 |
Correct |
1 ms |
384 KB |
Output is correct |
106 |
Correct |
2 ms |
384 KB |
Output is correct |