답안 #670803

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
670803 2022-12-10T15:01:30 Z thiago_bastos Wish (LMIO19_noras) C++17
93 / 100
430 ms 29616 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;
	ld delta = 1.0L * B * B - 4.0L * A * C;
	if(delta < -EPS) return false;
	delta = sqrt(delta);
	s1 = (-B - delta) / (2 * A);
	s2 = (-B + delta) / (2 * 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;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 260 KB Output is correct
12 Correct 0 ms 316 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 456 KB Output is correct
18 Correct 1 ms 456 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 328 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 260 KB Output is correct
12 Correct 0 ms 316 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 456 KB Output is correct
18 Correct 1 ms 456 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 328 KB Output is correct
23 Correct 90 ms 13228 KB Output is correct
24 Correct 85 ms 13856 KB Output is correct
25 Correct 93 ms 13924 KB Output is correct
26 Correct 89 ms 13824 KB Output is correct
27 Correct 59 ms 8396 KB Output is correct
28 Correct 73 ms 12952 KB Output is correct
29 Correct 73 ms 12920 KB Output is correct
30 Correct 71 ms 12864 KB Output is correct
31 Correct 81 ms 12948 KB Output is correct
32 Correct 146 ms 14024 KB Output is correct
33 Correct 140 ms 13964 KB Output is correct
34 Correct 146 ms 14048 KB Output is correct
35 Correct 151 ms 13936 KB Output is correct
36 Correct 147 ms 13976 KB Output is correct
37 Correct 62 ms 9940 KB Output is correct
38 Correct 65 ms 9800 KB Output is correct
39 Correct 56 ms 8116 KB Output is correct
40 Correct 61 ms 8668 KB Output is correct
41 Correct 59 ms 8052 KB Output is correct
42 Correct 57 ms 8240 KB Output is correct
43 Correct 410 ms 29532 KB Output is correct
44 Correct 415 ms 29588 KB Output is correct
45 Correct 423 ms 29516 KB Output is correct
46 Correct 430 ms 29616 KB Output is correct
47 Correct 406 ms 29516 KB Output is correct
48 Correct 342 ms 27944 KB Output is correct
49 Correct 342 ms 27852 KB Output is correct
50 Correct 339 ms 27908 KB Output is correct
51 Correct 342 ms 27836 KB Output is correct
52 Correct 339 ms 27844 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 260 KB Output is correct
12 Correct 0 ms 316 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 456 KB Output is correct
18 Correct 1 ms 456 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 328 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 1 ms 452 KB Output is correct
25 Correct 1 ms 460 KB Output is correct
26 Correct 1 ms 340 KB Output is correct
27 Correct 1 ms 328 KB Output is correct
28 Correct 1 ms 360 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 260 KB Output is correct
12 Correct 0 ms 316 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 456 KB Output is correct
18 Correct 1 ms 456 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 328 KB Output is correct
23 Correct 90 ms 13228 KB Output is correct
24 Correct 85 ms 13856 KB Output is correct
25 Correct 93 ms 13924 KB Output is correct
26 Correct 89 ms 13824 KB Output is correct
27 Correct 59 ms 8396 KB Output is correct
28 Correct 73 ms 12952 KB Output is correct
29 Correct 73 ms 12920 KB Output is correct
30 Correct 71 ms 12864 KB Output is correct
31 Correct 81 ms 12948 KB Output is correct
32 Correct 146 ms 14024 KB Output is correct
33 Correct 140 ms 13964 KB Output is correct
34 Correct 146 ms 14048 KB Output is correct
35 Correct 151 ms 13936 KB Output is correct
36 Correct 147 ms 13976 KB Output is correct
37 Correct 62 ms 9940 KB Output is correct
38 Correct 65 ms 9800 KB Output is correct
39 Correct 56 ms 8116 KB Output is correct
40 Correct 61 ms 8668 KB Output is correct
41 Correct 59 ms 8052 KB Output is correct
42 Correct 57 ms 8240 KB Output is correct
43 Correct 410 ms 29532 KB Output is correct
44 Correct 415 ms 29588 KB Output is correct
45 Correct 423 ms 29516 KB Output is correct
46 Correct 430 ms 29616 KB Output is correct
47 Correct 406 ms 29516 KB Output is correct
48 Correct 342 ms 27944 KB Output is correct
49 Correct 342 ms 27852 KB Output is correct
50 Correct 339 ms 27908 KB Output is correct
51 Correct 342 ms 27836 KB Output is correct
52 Correct 339 ms 27844 KB Output is correct
53 Correct 1 ms 212 KB Output is correct
54 Correct 1 ms 452 KB Output is correct
55 Correct 1 ms 460 KB Output is correct
56 Correct 1 ms 340 KB Output is correct
57 Correct 1 ms 328 KB Output is correct
58 Correct 1 ms 360 KB Output is correct
59 Correct 87 ms 13776 KB Output is correct
60 Correct 70 ms 8120 KB Output is correct
61 Correct 70 ms 8640 KB Output is correct
62 Correct 86 ms 9492 KB Output is correct
63 Correct 75 ms 8104 KB Output is correct
64 Correct 71 ms 7748 KB Output is correct
65 Correct 75 ms 7976 KB Output is correct
66 Correct 78 ms 8140 KB Output is correct
67 Correct 74 ms 7940 KB Output is correct
68 Correct 149 ms 14156 KB Output is correct
69 Correct 150 ms 14156 KB Output is correct
70 Correct 150 ms 14100 KB Output is correct
71 Correct 142 ms 14152 KB Output is correct
72 Correct 145 ms 14176 KB Output is correct
73 Correct 64 ms 9224 KB Output is correct
74 Correct 63 ms 10280 KB Output is correct
75 Correct 74 ms 11344 KB Output is correct
76 Correct 59 ms 8620 KB Output is correct
77 Correct 352 ms 26848 KB Output is correct
78 Correct 348 ms 26792 KB Output is correct
79 Correct 355 ms 26996 KB Output is correct
80 Correct 347 ms 26828 KB Output is correct
81 Correct 354 ms 26848 KB Output is correct
82 Correct 344 ms 28108 KB Output is correct
83 Correct 352 ms 28304 KB Output is correct
84 Correct 349 ms 28140 KB Output is correct
85 Correct 355 ms 28044 KB Output is correct
86 Correct 350 ms 28108 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 328 KB Output is correct
4 Correct 1 ms 352 KB Output is correct
5 Correct 1 ms 332 KB Output is correct
6 Correct 1 ms 328 KB Output is correct
7 Correct 1 ms 328 KB Output is correct
8 Correct 0 ms 212 KB Output is correct
9 Correct 0 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 260 KB Output is correct
12 Correct 0 ms 316 KB Output is correct
13 Correct 1 ms 320 KB Output is correct
14 Correct 2 ms 460 KB Output is correct
15 Correct 2 ms 340 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 456 KB Output is correct
18 Correct 1 ms 456 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 328 KB Output is correct
23 Correct 90 ms 13228 KB Output is correct
24 Correct 85 ms 13856 KB Output is correct
25 Correct 93 ms 13924 KB Output is correct
26 Correct 89 ms 13824 KB Output is correct
27 Correct 59 ms 8396 KB Output is correct
28 Correct 73 ms 12952 KB Output is correct
29 Correct 73 ms 12920 KB Output is correct
30 Correct 71 ms 12864 KB Output is correct
31 Correct 81 ms 12948 KB Output is correct
32 Correct 146 ms 14024 KB Output is correct
33 Correct 140 ms 13964 KB Output is correct
34 Correct 146 ms 14048 KB Output is correct
35 Correct 151 ms 13936 KB Output is correct
36 Correct 147 ms 13976 KB Output is correct
37 Correct 62 ms 9940 KB Output is correct
38 Correct 65 ms 9800 KB Output is correct
39 Correct 56 ms 8116 KB Output is correct
40 Correct 61 ms 8668 KB Output is correct
41 Correct 59 ms 8052 KB Output is correct
42 Correct 57 ms 8240 KB Output is correct
43 Correct 410 ms 29532 KB Output is correct
44 Correct 415 ms 29588 KB Output is correct
45 Correct 423 ms 29516 KB Output is correct
46 Correct 430 ms 29616 KB Output is correct
47 Correct 406 ms 29516 KB Output is correct
48 Correct 342 ms 27944 KB Output is correct
49 Correct 342 ms 27852 KB Output is correct
50 Correct 339 ms 27908 KB Output is correct
51 Correct 342 ms 27836 KB Output is correct
52 Correct 339 ms 27844 KB Output is correct
53 Correct 87 ms 13776 KB Output is correct
54 Correct 70 ms 8120 KB Output is correct
55 Correct 70 ms 8640 KB Output is correct
56 Correct 86 ms 9492 KB Output is correct
57 Correct 75 ms 8104 KB Output is correct
58 Correct 71 ms 7748 KB Output is correct
59 Correct 75 ms 7976 KB Output is correct
60 Correct 78 ms 8140 KB Output is correct
61 Correct 74 ms 7940 KB Output is correct
62 Correct 149 ms 14156 KB Output is correct
63 Correct 150 ms 14156 KB Output is correct
64 Correct 150 ms 14100 KB Output is correct
65 Correct 142 ms 14152 KB Output is correct
66 Correct 145 ms 14176 KB Output is correct
67 Correct 64 ms 9224 KB Output is correct
68 Correct 63 ms 10280 KB Output is correct
69 Correct 74 ms 11344 KB Output is correct
70 Correct 59 ms 8620 KB Output is correct
71 Correct 352 ms 26848 KB Output is correct
72 Correct 348 ms 26792 KB Output is correct
73 Correct 355 ms 26996 KB Output is correct
74 Correct 347 ms 26828 KB Output is correct
75 Correct 354 ms 26848 KB Output is correct
76 Correct 344 ms 28108 KB Output is correct
77 Correct 352 ms 28304 KB Output is correct
78 Correct 349 ms 28140 KB Output is correct
79 Correct 355 ms 28044 KB Output is correct
80 Correct 350 ms 28108 KB Output is correct
81 Correct 1 ms 212 KB Output is correct
82 Correct 1 ms 452 KB Output is correct
83 Correct 1 ms 460 KB Output is correct
84 Correct 1 ms 340 KB Output is correct
85 Correct 1 ms 328 KB Output is correct
86 Correct 1 ms 360 KB Output is correct
87 Correct 86 ms 9548 KB Output is correct
88 Correct 93 ms 9680 KB Output is correct
89 Correct 87 ms 9404 KB Output is correct
90 Correct 80 ms 9548 KB Output is correct
91 Correct 87 ms 9892 KB Output is correct
92 Correct 82 ms 9392 KB Output is correct
93 Correct 91 ms 9536 KB Output is correct
94 Correct 85 ms 9796 KB Output is correct
95 Correct 82 ms 9396 KB Output is correct
96 Correct 80 ms 9444 KB Output is correct
97 Correct 100 ms 14620 KB Output is correct
98 Incorrect 73 ms 10736 KB Output isn't correct
99 Halted 0 ms 0 KB -