# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
770967 |
2023-07-02T08:23:23 Z |
dxz05 |
Wish (LMIO19_noras) |
C++17 |
|
769 ms |
12012 KB |
//#pragma GCC optimize("Ofast,O3,unroll-loops")
//#pragma GCC target("avx,avx2")
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define bpc(x) __builtin_popcount(x)
#define bpcll(x) __builtin_popcountll(x)
#define MP make_pair
//#define endl '\n'
mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
typedef long long ll;
const int MOD = 1e9 + 7;
const int N = 2005;
#define loop for (int it = 0; it < 100; it++)
#define ld __int128
void solve(){
int n; ll R;
cin >> n >> R;
R *= R;
ld lim = 3e9;
vector<ld> st, en;
map<ld, int> mp;
for (int i = 1; i <= n; i++){
ll a, b, c, d;
cin >> a >> b >> c >> d;
auto dist = [&](ld t) -> ld{
ld x = c - a, y = d - b;
x = x * t + a;
y = y * t + b;
return x * x + y * y;
};
ld t = -1, dt = R + 5;
ld l = 0, r = lim;
loop{
ld m1 = l + (r - l) / 3;
ld m2 = r - (r - l) / 3;
ld f1 = dist(m1), f2 = dist(m2);
if (f1 < dt) t = m1, dt = f1;
if (f2 < dt) t = m2, dt = f2;
if (f1 < f2){
r = m2;
} else {
l = m1;
}
}
if (dt > R) continue;
ld _st = t, _en = t;
l = 0, r = t;
loop{
ld m = (l + r) / 2;
if (dist(m) <= R){
_st = min(_st, m);
r = m;
} else {
l = m;
}
}
l = t, r = lim;
loop{
ld m = (l + r) / 2;
if (dist(m) <= R){
_en = max(_en, m);
l = m;
} else {
r = m;
}
}
st.push_back(_st);
en.push_back(_en);
mp[_st] = mp[_en] = 0;
}
int z = 0;
for (auto &now : mp) now.second = ++z;
vector<int> cnt(z + 2, 0);
for (int i = 0; i < (int) st.size(); i++){
cnt[mp[st[i]]]++;
cnt[mp[en[i]] + 1]--;
}
int ans = 0;
for (int i = 1; i <= z + 1; i++){
cnt[i] += cnt[i - 1];
ans = max(ans, cnt[i]);
}
cout << ans << endl;
}
int main(){
clock_t startTime = clock();
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int test_cases = 1;
// cin >> test_cases;
for (int test = 1; test <= test_cases; test++){
//cout << (solve() ? "YES" : "NO") << endl;
solve();
}
#ifdef LOCAL
cerr << "Time: " << int((double) (clock() - startTime) / CLOCKS_PER_SEC * 1000) << " ms" << endl;
#endif
return 0;
}
Compilation message
noras.cpp: In function 'int main()':
noras.cpp:117:13: warning: unused variable 'startTime' [-Wunused-variable]
117 | clock_t startTime = clock();
| ^~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
2 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 |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
4 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
412 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
3 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
2 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 |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
4 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
412 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
3 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
289 ms |
3540 KB |
Output is correct |
24 |
Correct |
296 ms |
3536 KB |
Output is correct |
25 |
Correct |
290 ms |
3516 KB |
Output is correct |
26 |
Correct |
325 ms |
3540 KB |
Output is correct |
27 |
Correct |
235 ms |
2076 KB |
Output is correct |
28 |
Correct |
281 ms |
3588 KB |
Output is correct |
29 |
Correct |
285 ms |
3624 KB |
Output is correct |
30 |
Correct |
284 ms |
3632 KB |
Output is correct |
31 |
Correct |
300 ms |
3556 KB |
Output is correct |
32 |
Correct |
332 ms |
3568 KB |
Output is correct |
33 |
Correct |
330 ms |
3640 KB |
Output is correct |
34 |
Correct |
326 ms |
3644 KB |
Output is correct |
35 |
Correct |
328 ms |
3616 KB |
Output is correct |
36 |
Correct |
329 ms |
3592 KB |
Output is correct |
37 |
Correct |
285 ms |
2568 KB |
Output is correct |
38 |
Correct |
266 ms |
2528 KB |
Output is correct |
39 |
Correct |
249 ms |
2076 KB |
Output is correct |
40 |
Correct |
262 ms |
2200 KB |
Output is correct |
41 |
Correct |
248 ms |
2044 KB |
Output is correct |
42 |
Correct |
249 ms |
2044 KB |
Output is correct |
43 |
Correct |
759 ms |
8280 KB |
Output is correct |
44 |
Correct |
757 ms |
8784 KB |
Output is correct |
45 |
Correct |
769 ms |
8796 KB |
Output is correct |
46 |
Correct |
742 ms |
8904 KB |
Output is correct |
47 |
Correct |
744 ms |
8736 KB |
Output is correct |
48 |
Correct |
664 ms |
7364 KB |
Output is correct |
49 |
Correct |
661 ms |
7344 KB |
Output is correct |
50 |
Correct |
663 ms |
7368 KB |
Output is correct |
51 |
Correct |
662 ms |
7464 KB |
Output is correct |
52 |
Correct |
709 ms |
7408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
2 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 |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
4 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
412 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
3 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
0 ms |
212 KB |
Output is correct |
24 |
Correct |
3 ms |
340 KB |
Output is correct |
25 |
Correct |
4 ms |
340 KB |
Output is correct |
26 |
Correct |
3 ms |
340 KB |
Output is correct |
27 |
Correct |
3 ms |
364 KB |
Output is correct |
28 |
Correct |
3 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
2 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 |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
4 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
412 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
3 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
289 ms |
3540 KB |
Output is correct |
24 |
Correct |
296 ms |
3536 KB |
Output is correct |
25 |
Correct |
290 ms |
3516 KB |
Output is correct |
26 |
Correct |
325 ms |
3540 KB |
Output is correct |
27 |
Correct |
235 ms |
2076 KB |
Output is correct |
28 |
Correct |
281 ms |
3588 KB |
Output is correct |
29 |
Correct |
285 ms |
3624 KB |
Output is correct |
30 |
Correct |
284 ms |
3632 KB |
Output is correct |
31 |
Correct |
300 ms |
3556 KB |
Output is correct |
32 |
Correct |
332 ms |
3568 KB |
Output is correct |
33 |
Correct |
330 ms |
3640 KB |
Output is correct |
34 |
Correct |
326 ms |
3644 KB |
Output is correct |
35 |
Correct |
328 ms |
3616 KB |
Output is correct |
36 |
Correct |
329 ms |
3592 KB |
Output is correct |
37 |
Correct |
285 ms |
2568 KB |
Output is correct |
38 |
Correct |
266 ms |
2528 KB |
Output is correct |
39 |
Correct |
249 ms |
2076 KB |
Output is correct |
40 |
Correct |
262 ms |
2200 KB |
Output is correct |
41 |
Correct |
248 ms |
2044 KB |
Output is correct |
42 |
Correct |
249 ms |
2044 KB |
Output is correct |
43 |
Correct |
759 ms |
8280 KB |
Output is correct |
44 |
Correct |
757 ms |
8784 KB |
Output is correct |
45 |
Correct |
769 ms |
8796 KB |
Output is correct |
46 |
Correct |
742 ms |
8904 KB |
Output is correct |
47 |
Correct |
744 ms |
8736 KB |
Output is correct |
48 |
Correct |
664 ms |
7364 KB |
Output is correct |
49 |
Correct |
661 ms |
7344 KB |
Output is correct |
50 |
Correct |
663 ms |
7368 KB |
Output is correct |
51 |
Correct |
662 ms |
7464 KB |
Output is correct |
52 |
Correct |
709 ms |
7408 KB |
Output is correct |
53 |
Correct |
0 ms |
212 KB |
Output is correct |
54 |
Correct |
3 ms |
340 KB |
Output is correct |
55 |
Correct |
4 ms |
340 KB |
Output is correct |
56 |
Correct |
3 ms |
340 KB |
Output is correct |
57 |
Correct |
3 ms |
364 KB |
Output is correct |
58 |
Correct |
3 ms |
340 KB |
Output is correct |
59 |
Correct |
296 ms |
4216 KB |
Output is correct |
60 |
Correct |
239 ms |
2592 KB |
Output is correct |
61 |
Correct |
243 ms |
2696 KB |
Output is correct |
62 |
Correct |
249 ms |
2884 KB |
Output is correct |
63 |
Correct |
259 ms |
2988 KB |
Output is correct |
64 |
Correct |
258 ms |
2988 KB |
Output is correct |
65 |
Correct |
261 ms |
3072 KB |
Output is correct |
66 |
Correct |
259 ms |
3052 KB |
Output is correct |
67 |
Correct |
296 ms |
2976 KB |
Output is correct |
68 |
Correct |
339 ms |
4324 KB |
Output is correct |
69 |
Correct |
335 ms |
4228 KB |
Output is correct |
70 |
Correct |
370 ms |
4280 KB |
Output is correct |
71 |
Correct |
338 ms |
4320 KB |
Output is correct |
72 |
Correct |
357 ms |
4444 KB |
Output is correct |
73 |
Correct |
261 ms |
3024 KB |
Output is correct |
74 |
Correct |
281 ms |
4336 KB |
Output is correct |
75 |
Correct |
282 ms |
4268 KB |
Output is correct |
76 |
Correct |
263 ms |
2840 KB |
Output is correct |
77 |
Correct |
698 ms |
8656 KB |
Output is correct |
78 |
Correct |
707 ms |
8612 KB |
Output is correct |
79 |
Correct |
701 ms |
8664 KB |
Output is correct |
80 |
Correct |
705 ms |
8636 KB |
Output is correct |
81 |
Correct |
701 ms |
8672 KB |
Output is correct |
82 |
Correct |
667 ms |
7348 KB |
Output is correct |
83 |
Correct |
678 ms |
7388 KB |
Output is correct |
84 |
Correct |
717 ms |
7332 KB |
Output is correct |
85 |
Correct |
670 ms |
7320 KB |
Output is correct |
86 |
Correct |
720 ms |
7444 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
3 ms |
340 KB |
Output is correct |
4 |
Correct |
3 ms |
340 KB |
Output is correct |
5 |
Correct |
3 ms |
340 KB |
Output is correct |
6 |
Correct |
3 ms |
340 KB |
Output is correct |
7 |
Correct |
2 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 |
1 ms |
212 KB |
Output is correct |
11 |
Correct |
0 ms |
212 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
0 ms |
212 KB |
Output is correct |
14 |
Correct |
4 ms |
340 KB |
Output is correct |
15 |
Correct |
4 ms |
340 KB |
Output is correct |
16 |
Correct |
4 ms |
340 KB |
Output is correct |
17 |
Correct |
4 ms |
340 KB |
Output is correct |
18 |
Correct |
4 ms |
412 KB |
Output is correct |
19 |
Correct |
3 ms |
340 KB |
Output is correct |
20 |
Correct |
3 ms |
340 KB |
Output is correct |
21 |
Correct |
3 ms |
340 KB |
Output is correct |
22 |
Correct |
3 ms |
340 KB |
Output is correct |
23 |
Correct |
289 ms |
3540 KB |
Output is correct |
24 |
Correct |
296 ms |
3536 KB |
Output is correct |
25 |
Correct |
290 ms |
3516 KB |
Output is correct |
26 |
Correct |
325 ms |
3540 KB |
Output is correct |
27 |
Correct |
235 ms |
2076 KB |
Output is correct |
28 |
Correct |
281 ms |
3588 KB |
Output is correct |
29 |
Correct |
285 ms |
3624 KB |
Output is correct |
30 |
Correct |
284 ms |
3632 KB |
Output is correct |
31 |
Correct |
300 ms |
3556 KB |
Output is correct |
32 |
Correct |
332 ms |
3568 KB |
Output is correct |
33 |
Correct |
330 ms |
3640 KB |
Output is correct |
34 |
Correct |
326 ms |
3644 KB |
Output is correct |
35 |
Correct |
328 ms |
3616 KB |
Output is correct |
36 |
Correct |
329 ms |
3592 KB |
Output is correct |
37 |
Correct |
285 ms |
2568 KB |
Output is correct |
38 |
Correct |
266 ms |
2528 KB |
Output is correct |
39 |
Correct |
249 ms |
2076 KB |
Output is correct |
40 |
Correct |
262 ms |
2200 KB |
Output is correct |
41 |
Correct |
248 ms |
2044 KB |
Output is correct |
42 |
Correct |
249 ms |
2044 KB |
Output is correct |
43 |
Correct |
759 ms |
8280 KB |
Output is correct |
44 |
Correct |
757 ms |
8784 KB |
Output is correct |
45 |
Correct |
769 ms |
8796 KB |
Output is correct |
46 |
Correct |
742 ms |
8904 KB |
Output is correct |
47 |
Correct |
744 ms |
8736 KB |
Output is correct |
48 |
Correct |
664 ms |
7364 KB |
Output is correct |
49 |
Correct |
661 ms |
7344 KB |
Output is correct |
50 |
Correct |
663 ms |
7368 KB |
Output is correct |
51 |
Correct |
662 ms |
7464 KB |
Output is correct |
52 |
Correct |
709 ms |
7408 KB |
Output is correct |
53 |
Correct |
296 ms |
4216 KB |
Output is correct |
54 |
Correct |
239 ms |
2592 KB |
Output is correct |
55 |
Correct |
243 ms |
2696 KB |
Output is correct |
56 |
Correct |
249 ms |
2884 KB |
Output is correct |
57 |
Correct |
259 ms |
2988 KB |
Output is correct |
58 |
Correct |
258 ms |
2988 KB |
Output is correct |
59 |
Correct |
261 ms |
3072 KB |
Output is correct |
60 |
Correct |
259 ms |
3052 KB |
Output is correct |
61 |
Correct |
296 ms |
2976 KB |
Output is correct |
62 |
Correct |
339 ms |
4324 KB |
Output is correct |
63 |
Correct |
335 ms |
4228 KB |
Output is correct |
64 |
Correct |
370 ms |
4280 KB |
Output is correct |
65 |
Correct |
338 ms |
4320 KB |
Output is correct |
66 |
Correct |
357 ms |
4444 KB |
Output is correct |
67 |
Correct |
261 ms |
3024 KB |
Output is correct |
68 |
Correct |
281 ms |
4336 KB |
Output is correct |
69 |
Correct |
282 ms |
4268 KB |
Output is correct |
70 |
Correct |
263 ms |
2840 KB |
Output is correct |
71 |
Correct |
698 ms |
8656 KB |
Output is correct |
72 |
Correct |
707 ms |
8612 KB |
Output is correct |
73 |
Correct |
701 ms |
8664 KB |
Output is correct |
74 |
Correct |
705 ms |
8636 KB |
Output is correct |
75 |
Correct |
701 ms |
8672 KB |
Output is correct |
76 |
Correct |
667 ms |
7348 KB |
Output is correct |
77 |
Correct |
678 ms |
7388 KB |
Output is correct |
78 |
Correct |
717 ms |
7332 KB |
Output is correct |
79 |
Correct |
670 ms |
7320 KB |
Output is correct |
80 |
Correct |
720 ms |
7444 KB |
Output is correct |
81 |
Correct |
0 ms |
212 KB |
Output is correct |
82 |
Correct |
3 ms |
340 KB |
Output is correct |
83 |
Correct |
4 ms |
340 KB |
Output is correct |
84 |
Correct |
3 ms |
340 KB |
Output is correct |
85 |
Correct |
3 ms |
364 KB |
Output is correct |
86 |
Correct |
3 ms |
340 KB |
Output is correct |
87 |
Correct |
300 ms |
8832 KB |
Output is correct |
88 |
Correct |
300 ms |
11020 KB |
Output is correct |
89 |
Correct |
294 ms |
9496 KB |
Output is correct |
90 |
Correct |
281 ms |
8192 KB |
Output is correct |
91 |
Correct |
293 ms |
7236 KB |
Output is correct |
92 |
Correct |
297 ms |
11836 KB |
Output is correct |
93 |
Correct |
308 ms |
12012 KB |
Output is correct |
94 |
Correct |
304 ms |
11932 KB |
Output is correct |
95 |
Correct |
296 ms |
11736 KB |
Output is correct |
96 |
Correct |
332 ms |
11764 KB |
Output is correct |
97 |
Correct |
298 ms |
6020 KB |
Output is correct |
98 |
Correct |
306 ms |
5872 KB |
Output is correct |
99 |
Correct |
298 ms |
5804 KB |
Output is correct |
100 |
Correct |
295 ms |
5820 KB |
Output is correct |
101 |
Correct |
296 ms |
5748 KB |
Output is correct |
102 |
Correct |
298 ms |
5804 KB |
Output is correct |
103 |
Correct |
301 ms |
6064 KB |
Output is correct |
104 |
Correct |
302 ms |
5820 KB |
Output is correct |
105 |
Correct |
303 ms |
5832 KB |
Output is correct |
106 |
Correct |
300 ms |
5800 KB |
Output is correct |