Submission #670806

# Submission time Handle Problem Language Result Execution time Memory
670806 2022-12-10T15:23:42 Z thiago_bastos Wish (LMIO19_noras) C++17
100 / 100
480 ms 25368 KB
#include "bits/stdc++.h"

using namespace std;

#define INF 1000000000
#define INFLL 1000000000000000000ll
#define EPS 1e-9
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pb push_back
#define fi first
#define sc second

using i64 = long long;
using u64 = unsigned long long;
using ld = long double;
using ii = pair<int, int>;

int n, radius;

bool getSecs(int a, int b, int c, int d, ld& s1, ld& s2) {
	i64 C = (i64)a * a + (i64)b * b - (i64)radius * radius;
	i64 B = 2 * ((i64)a * c + (i64)b * d);
	i64 A = (i64)c * c + (i64)d * d;
	__int128 D = (__int128)B * B - (__int128)4 * A * C;
	if(D < 0) return false;
	ld delta = sqrt((ld)D);
	s1 = (-B - delta) / (2.0L * A);
	s2 = (-B + delta) / (2.0L * A); 
	return true;
}

void solve() {
	cin >> n >> radius;

	set<pair<i64, int>> sweep;
	int opening = 0, ans = 0;

	for(int i = 1; i <= n; ++i) {
		int a, b, c, d;
		ld s1, s2;

		cin >> a >> b >> c >> d;

		if(!getSecs(a, b, c - a, d - b, s1, s2)) continue;
		
		i64 l = max(0.0L, ceil(s1)), r = floor(s2); 
		
		if(l > r) continue;

		sweep.emplace(l, -i);
		sweep.emplace(r, i);
	}

	for(auto [x, k] : sweep) {
		opening += k < 0 ? 1 : -1;
		ans = max(ans, opening);
	}

	cout << ans << '\n';
}

int main() {
	ios_base :: sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	//cin >> t;
	while(t--) solve();
	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 0 ms 212 KB Output is correct
9 Correct 0 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 0 ms 212 KB Output is correct
13 Correct 0 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 368 KB Output is correct
18 Correct 2 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 0 ms 212 KB Output is correct
9 Correct 0 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 0 ms 212 KB Output is correct
13 Correct 0 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 368 KB Output is correct
18 Correct 2 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 88 ms 12320 KB Output is correct
24 Correct 84 ms 12288 KB Output is correct
25 Correct 84 ms 12248 KB Output is correct
26 Correct 84 ms 12228 KB Output is correct
27 Correct 62 ms 6524 KB Output is correct
28 Correct 76 ms 11176 KB Output is correct
29 Correct 75 ms 11268 KB Output is correct
30 Correct 78 ms 11244 KB Output is correct
31 Correct 77 ms 11192 KB Output is correct
32 Correct 142 ms 12308 KB Output is correct
33 Correct 141 ms 12332 KB Output is correct
34 Correct 134 ms 12336 KB Output is correct
35 Correct 132 ms 12216 KB Output is correct
36 Correct 143 ms 12236 KB Output is correct
37 Correct 71 ms 8480 KB Output is correct
38 Correct 67 ms 8300 KB Output is correct
39 Correct 61 ms 6448 KB Output is correct
40 Correct 63 ms 7068 KB Output is correct
41 Correct 60 ms 6440 KB Output is correct
42 Correct 63 ms 6484 KB Output is correct
43 Correct 385 ms 25260 KB Output is correct
44 Correct 480 ms 25316 KB Output is correct
45 Correct 403 ms 25284 KB Output is correct
46 Correct 398 ms 25368 KB Output is correct
47 Correct 391 ms 25332 KB Output is correct
48 Correct 325 ms 24368 KB Output is correct
49 Correct 329 ms 24460 KB Output is correct
50 Correct 324 ms 24368 KB Output is correct
51 Correct 336 ms 24300 KB Output is correct
52 Correct 343 ms 24392 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 0 ms 212 KB Output is correct
9 Correct 0 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 0 ms 212 KB Output is correct
13 Correct 0 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 368 KB Output is correct
18 Correct 2 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 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 0 ms 212 KB Output is correct
9 Correct 0 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 0 ms 212 KB Output is correct
13 Correct 0 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 368 KB Output is correct
18 Correct 2 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 88 ms 12320 KB Output is correct
24 Correct 84 ms 12288 KB Output is correct
25 Correct 84 ms 12248 KB Output is correct
26 Correct 84 ms 12228 KB Output is correct
27 Correct 62 ms 6524 KB Output is correct
28 Correct 76 ms 11176 KB Output is correct
29 Correct 75 ms 11268 KB Output is correct
30 Correct 78 ms 11244 KB Output is correct
31 Correct 77 ms 11192 KB Output is correct
32 Correct 142 ms 12308 KB Output is correct
33 Correct 141 ms 12332 KB Output is correct
34 Correct 134 ms 12336 KB Output is correct
35 Correct 132 ms 12216 KB Output is correct
36 Correct 143 ms 12236 KB Output is correct
37 Correct 71 ms 8480 KB Output is correct
38 Correct 67 ms 8300 KB Output is correct
39 Correct 61 ms 6448 KB Output is correct
40 Correct 63 ms 7068 KB Output is correct
41 Correct 60 ms 6440 KB Output is correct
42 Correct 63 ms 6484 KB Output is correct
43 Correct 385 ms 25260 KB Output is correct
44 Correct 480 ms 25316 KB Output is correct
45 Correct 403 ms 25284 KB Output is correct
46 Correct 398 ms 25368 KB Output is correct
47 Correct 391 ms 25332 KB Output is correct
48 Correct 325 ms 24368 KB Output is correct
49 Correct 329 ms 24460 KB Output is correct
50 Correct 324 ms 24368 KB Output is correct
51 Correct 336 ms 24300 KB Output is correct
52 Correct 343 ms 24392 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 1 ms 340 KB Output is correct
59 Correct 86 ms 12268 KB Output is correct
60 Correct 64 ms 6140 KB Output is correct
61 Correct 70 ms 6500 KB Output is correct
62 Correct 65 ms 7256 KB Output is correct
63 Correct 77 ms 6160 KB Output is correct
64 Correct 72 ms 5708 KB Output is correct
65 Correct 75 ms 5876 KB Output is correct
66 Correct 72 ms 6092 KB Output is correct
67 Correct 73 ms 5876 KB Output is correct
68 Correct 147 ms 12364 KB Output is correct
69 Correct 137 ms 12328 KB Output is correct
70 Correct 139 ms 12236 KB Output is correct
71 Correct 147 ms 12328 KB Output is correct
72 Correct 144 ms 12332 KB Output is correct
73 Correct 72 ms 7856 KB Output is correct
74 Correct 72 ms 8652 KB Output is correct
75 Correct 77 ms 9780 KB Output is correct
76 Correct 64 ms 6840 KB Output is correct
77 Correct 363 ms 22492 KB Output is correct
78 Correct 321 ms 22580 KB Output is correct
79 Correct 334 ms 22508 KB Output is correct
80 Correct 338 ms 22608 KB Output is correct
81 Correct 328 ms 22736 KB Output is correct
82 Correct 342 ms 24448 KB Output is correct
83 Correct 339 ms 24268 KB Output is correct
84 Correct 341 ms 24376 KB Output is correct
85 Correct 337 ms 24348 KB Output is correct
86 Correct 341 ms 24524 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 0 ms 212 KB Output is correct
9 Correct 0 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 0 ms 212 KB Output is correct
13 Correct 0 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 368 KB Output is correct
18 Correct 2 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 88 ms 12320 KB Output is correct
24 Correct 84 ms 12288 KB Output is correct
25 Correct 84 ms 12248 KB Output is correct
26 Correct 84 ms 12228 KB Output is correct
27 Correct 62 ms 6524 KB Output is correct
28 Correct 76 ms 11176 KB Output is correct
29 Correct 75 ms 11268 KB Output is correct
30 Correct 78 ms 11244 KB Output is correct
31 Correct 77 ms 11192 KB Output is correct
32 Correct 142 ms 12308 KB Output is correct
33 Correct 141 ms 12332 KB Output is correct
34 Correct 134 ms 12336 KB Output is correct
35 Correct 132 ms 12216 KB Output is correct
36 Correct 143 ms 12236 KB Output is correct
37 Correct 71 ms 8480 KB Output is correct
38 Correct 67 ms 8300 KB Output is correct
39 Correct 61 ms 6448 KB Output is correct
40 Correct 63 ms 7068 KB Output is correct
41 Correct 60 ms 6440 KB Output is correct
42 Correct 63 ms 6484 KB Output is correct
43 Correct 385 ms 25260 KB Output is correct
44 Correct 480 ms 25316 KB Output is correct
45 Correct 403 ms 25284 KB Output is correct
46 Correct 398 ms 25368 KB Output is correct
47 Correct 391 ms 25332 KB Output is correct
48 Correct 325 ms 24368 KB Output is correct
49 Correct 329 ms 24460 KB Output is correct
50 Correct 324 ms 24368 KB Output is correct
51 Correct 336 ms 24300 KB Output is correct
52 Correct 343 ms 24392 KB Output is correct
53 Correct 86 ms 12268 KB Output is correct
54 Correct 64 ms 6140 KB Output is correct
55 Correct 70 ms 6500 KB Output is correct
56 Correct 65 ms 7256 KB Output is correct
57 Correct 77 ms 6160 KB Output is correct
58 Correct 72 ms 5708 KB Output is correct
59 Correct 75 ms 5876 KB Output is correct
60 Correct 72 ms 6092 KB Output is correct
61 Correct 73 ms 5876 KB Output is correct
62 Correct 147 ms 12364 KB Output is correct
63 Correct 137 ms 12328 KB Output is correct
64 Correct 139 ms 12236 KB Output is correct
65 Correct 147 ms 12328 KB Output is correct
66 Correct 144 ms 12332 KB Output is correct
67 Correct 72 ms 7856 KB Output is correct
68 Correct 72 ms 8652 KB Output is correct
69 Correct 77 ms 9780 KB Output is correct
70 Correct 64 ms 6840 KB Output is correct
71 Correct 363 ms 22492 KB Output is correct
72 Correct 321 ms 22580 KB Output is correct
73 Correct 334 ms 22508 KB Output is correct
74 Correct 338 ms 22608 KB Output is correct
75 Correct 328 ms 22736 KB Output is correct
76 Correct 342 ms 24448 KB Output is correct
77 Correct 339 ms 24268 KB Output is correct
78 Correct 341 ms 24376 KB Output is correct
79 Correct 337 ms 24348 KB Output is correct
80 Correct 341 ms 24524 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 1 ms 340 KB Output is correct
87 Correct 81 ms 5948 KB Output is correct
88 Correct 78 ms 6016 KB Output is correct
89 Correct 77 ms 5792 KB Output is correct
90 Correct 83 ms 5900 KB Output is correct
91 Correct 86 ms 6204 KB Output is correct
92 Correct 77 ms 5768 KB Output is correct
93 Correct 77 ms 5892 KB Output is correct
94 Correct 79 ms 6132 KB Output is correct
95 Correct 75 ms 5772 KB Output is correct
96 Correct 83 ms 5776 KB Output is correct
97 Correct 91 ms 12236 KB Output is correct
98 Correct 88 ms 12252 KB Output is correct
99 Correct 89 ms 14692 KB Output is correct
100 Correct 93 ms 14724 KB Output is correct
101 Correct 95 ms 14644 KB Output is correct
102 Correct 92 ms 14576 KB Output is correct
103 Correct 90 ms 14592 KB Output is correct
104 Correct 92 ms 14652 KB Output is correct
105 Correct 90 ms 14596 KB Output is correct
106 Correct 94 ms 14600 KB Output is correct