Submission #253203

# Submission time Handle Problem Language Result Execution time Memory
253203 2020-07-27T12:02:25 Z nandonathaniel Wish (LMIO19_noras) C++14
100 / 100
296 ms 4736 KB
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;

int main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	int n;
	vector<pii> segment;
	double r,A,B,C,D,vA,vB;
	cin >> n >> r;
	for(int i=1;i<=n;i++){
		cin >> A >> B >> C >> D;
		vA=C-A;vB=D-B;
		if(A!=C){
			double m=(D-B)/(C-A);
			double c=B-m*A;
			double disk=m*m*c*c-(m*m+1.0)*(c*c-r*r);
			if(disk<0.0)continue;
			disk=sqrt(disk);
			double x1=(-1.0*m*c+disk)/(m*m+1.0),x2=(-1.0*m*c-disk)/(m*m+1.0);
			double time1=(x1-A)/vA+1.0,time2=(x2-A)/vA+1.0;
			if(time2<time1)swap(time1,time2);
			if(time2<1.0)continue;
			if(time1<1.0)time1=1.0;
			int masuk=(int)ceil(time1),keluar=(int)floor(time2)+1;
			if(keluar>masuk){
				segment.push_back({masuk,i});
				segment.push_back({keluar,-i});
			}
		}
		else{
			double val=r*r-A*A;
			if(val<0.0)continue;
			val=sqrt(val);
			double y1=-1.0*val,y2=val;
			double time1=(y1-B)/vB+1.0,time2=(y2-B)/vB+1.0;
			if(time2<time1)swap(time1,time2);
			if(time2<1.0)continue;
			if(time1<1.0)time1=1.0;
			int masuk=(int)ceil(time1),keluar=(int)floor(time2)+1;
			if(keluar>masuk){
				segment.push_back({masuk,i});
				segment.push_back({keluar,-i});
			}
		}
	}
	sort(segment.begin(),segment.end());
	int ans=0,active=0;
	for(auto isi : segment){
		if(isi.second>0)active++;
		else active--;
		ans=max(ans,active);
	}
	cout << ans << '\n';
	return 0;
}
# 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 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 1 ms 256 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 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 1 ms 256 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 120 ms 2592 KB Output is correct
24 Correct 122 ms 2672 KB Output is correct
25 Correct 123 ms 2544 KB Output is correct
26 Correct 123 ms 2684 KB Output is correct
27 Correct 122 ms 1532 KB Output is correct
28 Correct 122 ms 2544 KB Output is correct
29 Correct 126 ms 2544 KB Output is correct
30 Correct 131 ms 2540 KB Output is correct
31 Correct 128 ms 2540 KB Output is correct
32 Correct 140 ms 2540 KB Output is correct
33 Correct 140 ms 2544 KB Output is correct
34 Correct 143 ms 2544 KB Output is correct
35 Correct 138 ms 2544 KB Output is correct
36 Correct 135 ms 2516 KB Output is correct
37 Correct 120 ms 1524 KB Output is correct
38 Correct 118 ms 1528 KB Output is correct
39 Correct 119 ms 1524 KB Output is correct
40 Correct 118 ms 1524 KB Output is correct
41 Correct 117 ms 1524 KB Output is correct
42 Correct 119 ms 1524 KB Output is correct
43 Correct 296 ms 4720 KB Output is correct
44 Correct 290 ms 4736 KB Output is correct
45 Correct 280 ms 4584 KB Output is correct
46 Correct 280 ms 4584 KB Output is correct
47 Correct 277 ms 4584 KB Output is correct
48 Correct 274 ms 4716 KB Output is correct
49 Correct 280 ms 4456 KB Output is correct
50 Correct 278 ms 4712 KB Output is correct
51 Correct 274 ms 4588 KB Output is correct
52 Correct 287 ms 4584 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 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 1 ms 256 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 2 ms 384 KB Output is correct
25 Correct 3 ms 384 KB Output is correct
26 Correct 2 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 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 1 ms 256 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 120 ms 2592 KB Output is correct
24 Correct 122 ms 2672 KB Output is correct
25 Correct 123 ms 2544 KB Output is correct
26 Correct 123 ms 2684 KB Output is correct
27 Correct 122 ms 1532 KB Output is correct
28 Correct 122 ms 2544 KB Output is correct
29 Correct 126 ms 2544 KB Output is correct
30 Correct 131 ms 2540 KB Output is correct
31 Correct 128 ms 2540 KB Output is correct
32 Correct 140 ms 2540 KB Output is correct
33 Correct 140 ms 2544 KB Output is correct
34 Correct 143 ms 2544 KB Output is correct
35 Correct 138 ms 2544 KB Output is correct
36 Correct 135 ms 2516 KB Output is correct
37 Correct 120 ms 1524 KB Output is correct
38 Correct 118 ms 1528 KB Output is correct
39 Correct 119 ms 1524 KB Output is correct
40 Correct 118 ms 1524 KB Output is correct
41 Correct 117 ms 1524 KB Output is correct
42 Correct 119 ms 1524 KB Output is correct
43 Correct 296 ms 4720 KB Output is correct
44 Correct 290 ms 4736 KB Output is correct
45 Correct 280 ms 4584 KB Output is correct
46 Correct 280 ms 4584 KB Output is correct
47 Correct 277 ms 4584 KB Output is correct
48 Correct 274 ms 4716 KB Output is correct
49 Correct 280 ms 4456 KB Output is correct
50 Correct 278 ms 4712 KB Output is correct
51 Correct 274 ms 4588 KB Output is correct
52 Correct 287 ms 4584 KB Output is correct
53 Correct 123 ms 2524 KB Output is correct
54 Correct 143 ms 1468 KB Output is correct
55 Correct 127 ms 1524 KB Output is correct
56 Correct 124 ms 1520 KB Output is correct
57 Correct 124 ms 1524 KB Output is correct
58 Correct 125 ms 1520 KB Output is correct
59 Correct 127 ms 1524 KB Output is correct
60 Correct 128 ms 1524 KB Output is correct
61 Correct 123 ms 1524 KB Output is correct
62 Correct 137 ms 2544 KB Output is correct
63 Correct 137 ms 2544 KB Output is correct
64 Correct 141 ms 2544 KB Output is correct
65 Correct 147 ms 2540 KB Output is correct
66 Correct 144 ms 2540 KB Output is correct
67 Correct 114 ms 1524 KB Output is correct
68 Correct 119 ms 2544 KB Output is correct
69 Correct 121 ms 2544 KB Output is correct
70 Correct 123 ms 1524 KB Output is correct
71 Correct 284 ms 4712 KB Output is correct
72 Correct 276 ms 4584 KB Output is correct
73 Correct 274 ms 4584 KB Output is correct
74 Correct 282 ms 4724 KB Output is correct
75 Correct 284 ms 4584 KB Output is correct
76 Correct 281 ms 4584 KB Output is correct
77 Correct 295 ms 4708 KB Output is correct
78 Correct 281 ms 4584 KB Output is correct
79 Correct 281 ms 4684 KB Output is correct
80 Correct 273 ms 4584 KB Output is correct
81 Correct 0 ms 384 KB Output is correct
82 Correct 2 ms 384 KB Output is correct
83 Correct 3 ms 384 KB Output is correct
84 Correct 2 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 2 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 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 2 ms 384 KB Output is correct
15 Correct 2 ms 384 KB Output is correct
16 Correct 2 ms 384 KB Output is correct
17 Correct 2 ms 384 KB Output is correct
18 Correct 3 ms 384 KB Output is correct
19 Correct 1 ms 256 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 120 ms 2592 KB Output is correct
24 Correct 122 ms 2672 KB Output is correct
25 Correct 123 ms 2544 KB Output is correct
26 Correct 123 ms 2684 KB Output is correct
27 Correct 122 ms 1532 KB Output is correct
28 Correct 122 ms 2544 KB Output is correct
29 Correct 126 ms 2544 KB Output is correct
30 Correct 131 ms 2540 KB Output is correct
31 Correct 128 ms 2540 KB Output is correct
32 Correct 140 ms 2540 KB Output is correct
33 Correct 140 ms 2544 KB Output is correct
34 Correct 143 ms 2544 KB Output is correct
35 Correct 138 ms 2544 KB Output is correct
36 Correct 135 ms 2516 KB Output is correct
37 Correct 120 ms 1524 KB Output is correct
38 Correct 118 ms 1528 KB Output is correct
39 Correct 119 ms 1524 KB Output is correct
40 Correct 118 ms 1524 KB Output is correct
41 Correct 117 ms 1524 KB Output is correct
42 Correct 119 ms 1524 KB Output is correct
43 Correct 296 ms 4720 KB Output is correct
44 Correct 290 ms 4736 KB Output is correct
45 Correct 280 ms 4584 KB Output is correct
46 Correct 280 ms 4584 KB Output is correct
47 Correct 277 ms 4584 KB Output is correct
48 Correct 274 ms 4716 KB Output is correct
49 Correct 280 ms 4456 KB Output is correct
50 Correct 278 ms 4712 KB Output is correct
51 Correct 274 ms 4588 KB Output is correct
52 Correct 287 ms 4584 KB Output is correct
53 Correct 123 ms 2524 KB Output is correct
54 Correct 143 ms 1468 KB Output is correct
55 Correct 127 ms 1524 KB Output is correct
56 Correct 124 ms 1520 KB Output is correct
57 Correct 124 ms 1524 KB Output is correct
58 Correct 125 ms 1520 KB Output is correct
59 Correct 127 ms 1524 KB Output is correct
60 Correct 128 ms 1524 KB Output is correct
61 Correct 123 ms 1524 KB Output is correct
62 Correct 137 ms 2544 KB Output is correct
63 Correct 137 ms 2544 KB Output is correct
64 Correct 141 ms 2544 KB Output is correct
65 Correct 147 ms 2540 KB Output is correct
66 Correct 144 ms 2540 KB Output is correct
67 Correct 114 ms 1524 KB Output is correct
68 Correct 119 ms 2544 KB Output is correct
69 Correct 121 ms 2544 KB Output is correct
70 Correct 123 ms 1524 KB Output is correct
71 Correct 284 ms 4712 KB Output is correct
72 Correct 276 ms 4584 KB Output is correct
73 Correct 274 ms 4584 KB Output is correct
74 Correct 282 ms 4724 KB Output is correct
75 Correct 284 ms 4584 KB Output is correct
76 Correct 281 ms 4584 KB Output is correct
77 Correct 295 ms 4708 KB Output is correct
78 Correct 281 ms 4584 KB Output is correct
79 Correct 281 ms 4684 KB Output is correct
80 Correct 273 ms 4584 KB Output is correct
81 Correct 154 ms 1548 KB Output is correct
82 Correct 158 ms 1524 KB Output is correct
83 Correct 157 ms 1544 KB Output is correct
84 Correct 161 ms 1524 KB Output is correct
85 Correct 161 ms 1520 KB Output is correct
86 Correct 166 ms 1492 KB Output is correct
87 Correct 150 ms 1524 KB Output is correct
88 Correct 151 ms 1528 KB Output is correct
89 Correct 150 ms 1524 KB Output is correct
90 Correct 148 ms 1524 KB Output is correct
91 Correct 128 ms 2540 KB Output is correct
92 Correct 140 ms 2568 KB Output is correct
93 Correct 129 ms 2544 KB Output is correct
94 Correct 128 ms 2668 KB Output is correct
95 Correct 128 ms 2544 KB Output is correct
96 Correct 132 ms 2556 KB Output is correct
97 Correct 130 ms 2544 KB Output is correct
98 Correct 127 ms 2540 KB Output is correct
99 Correct 138 ms 2544 KB Output is correct
100 Correct 127 ms 2544 KB Output is correct
101 Correct 0 ms 384 KB Output is correct
102 Correct 2 ms 384 KB Output is correct
103 Correct 3 ms 384 KB Output is correct
104 Correct 2 ms 384 KB Output is correct
105 Correct 1 ms 384 KB Output is correct
106 Correct 2 ms 384 KB Output is correct