답안 #639187

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639187 2022-09-08T22:07:35 Z Pietra Wish (LMIO19_noras) C++14
100 / 100
238 ms 14956 KB
#include<bits/stdc++.h>
#define int long long
using namespace std ;

const int maxn = 2e5 + 5 ;

int n, r, xi[maxn], xf[maxn], yi[maxn], yf[maxn] ;
vector<pair<int,int>> inter ;

bool test(int a, int b, int c, int x){ return (a*x*x + b*x + c <= 0) ; }

pair<int,int> bsk(double a, double b, double c){
    double d = (b*b) - (4*a*c) ;
    if(d < 0) return {1, 0} ;
    double k = (-b - sqrt(d))*1.00/(2*a*1.00) ;
    double k2 = (-b + sqrt(d))*1.00/(2*a*1.00) ;
    if(k < 0 && k2 < 0) return {1, 0} ;
    if(k < 0) k = 0LL ;
    if(k2 < 0) k2 = 0LL ;
    //cout << a << " " << b << " " << c << " " << d << " " << k2 << "\n" ;
    return {k, k2} ;
}


int32_t main(){

    cin >> n >> r ;

    for(int i = 1 ; i <= n ; i++) cin >> xi[i] >> yi[i] >> xf[i] >> yf[i] ;

    for(int i = 1 ; i <= n ; i++){
        int dx = (xf[i]-xi[i]), dy = (yf[i]-yi[i]) ;
        int a = ((dx*dx)+(dy*dy)) ;
        int b = (2*xi[i]*dx) + (2*yi[i]*dy) ;
        int c = (xi[i]*xi[i]) + (yi[i]*yi[i]) - (r*r) ;
        //cout << a << " " << b << " " << c << "\n" ;
        pair<int,int> x = bsk(a, b, c) ;
        int r1 = x.first, r2 = x.second ;
        bool ok = 0 ;
        for(int j = max(0LL, r1 - 2) ; j <= r1 + 2 ; j++){
            int px = xi[i] + (dx*j) ;
            int py = yi[i] + (dy*j) ;
            if((px*px) + (py*py) <= r*r){
                ok = 1 ; r1 = j ; break ;
            }
        }
        for(int j = r2 + 2 ; j >= max(0LL, r2-2) ; j--){
            int px = xi[i] + (dx*j), py = yi[i] + (dy*j) ;
            if((px*px) + (py*py) <= r*r){
                ok = 1 ;
                r2 = j ; break ;
            }
        }
        if(!ok) continue ;
        inter.push_back({r1, 0}) ; inter.push_back({r2, 1}) ;
    }

    int ans = 0, sm = 0 ;

    sort(inter.begin(), inter.end()) ;

    //for(auto a : inter) cout << a.first << " " << a.second << "\n" ;

    for(auto a : inter){
        if(a.second) sm-- ;
        else sm++ ;
        ans = max(ans, sm) ;
    }

    cout << ans << "\n" ;

}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 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 340 KB Output is correct
18 Correct 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 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 340 KB Output is correct
18 Correct 1 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 98 ms 7656 KB Output is correct
24 Correct 90 ms 7592 KB Output is correct
25 Correct 89 ms 7672 KB Output is correct
26 Correct 88 ms 7656 KB Output is correct
27 Correct 96 ms 5532 KB Output is correct
28 Correct 96 ms 7644 KB Output is correct
29 Correct 95 ms 7632 KB Output is correct
30 Correct 93 ms 7688 KB Output is correct
31 Correct 98 ms 7596 KB Output is correct
32 Correct 100 ms 7660 KB Output is correct
33 Correct 113 ms 7612 KB Output is correct
34 Correct 114 ms 7584 KB Output is correct
35 Correct 99 ms 7612 KB Output is correct
36 Correct 103 ms 7564 KB Output is correct
37 Correct 90 ms 5568 KB Output is correct
38 Correct 102 ms 5584 KB Output is correct
39 Correct 83 ms 5588 KB Output is correct
40 Correct 89 ms 5576 KB Output is correct
41 Correct 86 ms 5508 KB Output is correct
42 Correct 101 ms 5560 KB Output is correct
43 Correct 228 ms 14956 KB Output is correct
44 Correct 221 ms 14900 KB Output is correct
45 Correct 231 ms 14892 KB Output is correct
46 Correct 238 ms 14884 KB Output is correct
47 Correct 222 ms 14892 KB Output is correct
48 Correct 198 ms 14836 KB Output is correct
49 Correct 236 ms 14880 KB Output is correct
50 Correct 196 ms 14896 KB Output is correct
51 Correct 198 ms 14896 KB Output is correct
52 Correct 208 ms 14864 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 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 340 KB Output is correct
18 Correct 1 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 1 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
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 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 340 KB Output is correct
18 Correct 1 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 98 ms 7656 KB Output is correct
24 Correct 90 ms 7592 KB Output is correct
25 Correct 89 ms 7672 KB Output is correct
26 Correct 88 ms 7656 KB Output is correct
27 Correct 96 ms 5532 KB Output is correct
28 Correct 96 ms 7644 KB Output is correct
29 Correct 95 ms 7632 KB Output is correct
30 Correct 93 ms 7688 KB Output is correct
31 Correct 98 ms 7596 KB Output is correct
32 Correct 100 ms 7660 KB Output is correct
33 Correct 113 ms 7612 KB Output is correct
34 Correct 114 ms 7584 KB Output is correct
35 Correct 99 ms 7612 KB Output is correct
36 Correct 103 ms 7564 KB Output is correct
37 Correct 90 ms 5568 KB Output is correct
38 Correct 102 ms 5584 KB Output is correct
39 Correct 83 ms 5588 KB Output is correct
40 Correct 89 ms 5576 KB Output is correct
41 Correct 86 ms 5508 KB Output is correct
42 Correct 101 ms 5560 KB Output is correct
43 Correct 228 ms 14956 KB Output is correct
44 Correct 221 ms 14900 KB Output is correct
45 Correct 231 ms 14892 KB Output is correct
46 Correct 238 ms 14884 KB Output is correct
47 Correct 222 ms 14892 KB Output is correct
48 Correct 198 ms 14836 KB Output is correct
49 Correct 236 ms 14880 KB Output is correct
50 Correct 196 ms 14896 KB Output is correct
51 Correct 198 ms 14896 KB Output is correct
52 Correct 208 ms 14864 KB Output is correct
53 Correct 0 ms 212 KB Output is correct
54 Correct 1 ms 340 KB Output is correct
55 Correct 1 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 88 ms 7608 KB Output is correct
60 Correct 109 ms 5660 KB Output is correct
61 Correct 103 ms 5536 KB Output is correct
62 Correct 100 ms 5600 KB Output is correct
63 Correct 103 ms 5568 KB Output is correct
64 Correct 107 ms 5588 KB Output is correct
65 Correct 115 ms 5560 KB Output is correct
66 Correct 105 ms 5544 KB Output is correct
67 Correct 101 ms 5572 KB Output is correct
68 Correct 103 ms 7612 KB Output is correct
69 Correct 104 ms 7672 KB Output is correct
70 Correct 140 ms 7612 KB Output is correct
71 Correct 106 ms 7572 KB Output is correct
72 Correct 107 ms 7568 KB Output is correct
73 Correct 90 ms 5588 KB Output is correct
74 Correct 93 ms 7640 KB Output is correct
75 Correct 91 ms 7684 KB Output is correct
76 Correct 103 ms 5580 KB Output is correct
77 Correct 225 ms 14820 KB Output is correct
78 Correct 222 ms 14924 KB Output is correct
79 Correct 221 ms 14832 KB Output is correct
80 Correct 233 ms 14844 KB Output is correct
81 Correct 225 ms 14860 KB Output is correct
82 Correct 233 ms 14780 KB Output is correct
83 Correct 210 ms 14844 KB Output is correct
84 Correct 208 ms 14904 KB Output is correct
85 Correct 215 ms 14824 KB Output is correct
86 Correct 224 ms 14888 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 2 ms 340 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 1 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 1 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 2 ms 340 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 340 KB Output is correct
18 Correct 1 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 98 ms 7656 KB Output is correct
24 Correct 90 ms 7592 KB Output is correct
25 Correct 89 ms 7672 KB Output is correct
26 Correct 88 ms 7656 KB Output is correct
27 Correct 96 ms 5532 KB Output is correct
28 Correct 96 ms 7644 KB Output is correct
29 Correct 95 ms 7632 KB Output is correct
30 Correct 93 ms 7688 KB Output is correct
31 Correct 98 ms 7596 KB Output is correct
32 Correct 100 ms 7660 KB Output is correct
33 Correct 113 ms 7612 KB Output is correct
34 Correct 114 ms 7584 KB Output is correct
35 Correct 99 ms 7612 KB Output is correct
36 Correct 103 ms 7564 KB Output is correct
37 Correct 90 ms 5568 KB Output is correct
38 Correct 102 ms 5584 KB Output is correct
39 Correct 83 ms 5588 KB Output is correct
40 Correct 89 ms 5576 KB Output is correct
41 Correct 86 ms 5508 KB Output is correct
42 Correct 101 ms 5560 KB Output is correct
43 Correct 228 ms 14956 KB Output is correct
44 Correct 221 ms 14900 KB Output is correct
45 Correct 231 ms 14892 KB Output is correct
46 Correct 238 ms 14884 KB Output is correct
47 Correct 222 ms 14892 KB Output is correct
48 Correct 198 ms 14836 KB Output is correct
49 Correct 236 ms 14880 KB Output is correct
50 Correct 196 ms 14896 KB Output is correct
51 Correct 198 ms 14896 KB Output is correct
52 Correct 208 ms 14864 KB Output is correct
53 Correct 88 ms 7608 KB Output is correct
54 Correct 109 ms 5660 KB Output is correct
55 Correct 103 ms 5536 KB Output is correct
56 Correct 100 ms 5600 KB Output is correct
57 Correct 103 ms 5568 KB Output is correct
58 Correct 107 ms 5588 KB Output is correct
59 Correct 115 ms 5560 KB Output is correct
60 Correct 105 ms 5544 KB Output is correct
61 Correct 101 ms 5572 KB Output is correct
62 Correct 103 ms 7612 KB Output is correct
63 Correct 104 ms 7672 KB Output is correct
64 Correct 140 ms 7612 KB Output is correct
65 Correct 106 ms 7572 KB Output is correct
66 Correct 107 ms 7568 KB Output is correct
67 Correct 90 ms 5588 KB Output is correct
68 Correct 93 ms 7640 KB Output is correct
69 Correct 91 ms 7684 KB Output is correct
70 Correct 103 ms 5580 KB Output is correct
71 Correct 225 ms 14820 KB Output is correct
72 Correct 222 ms 14924 KB Output is correct
73 Correct 221 ms 14832 KB Output is correct
74 Correct 233 ms 14844 KB Output is correct
75 Correct 225 ms 14860 KB Output is correct
76 Correct 233 ms 14780 KB Output is correct
77 Correct 210 ms 14844 KB Output is correct
78 Correct 208 ms 14904 KB Output is correct
79 Correct 215 ms 14824 KB Output is correct
80 Correct 224 ms 14888 KB Output is correct
81 Correct 0 ms 212 KB Output is correct
82 Correct 1 ms 340 KB Output is correct
83 Correct 1 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 144 ms 5520 KB Output is correct
88 Correct 152 ms 9268 KB Output is correct
89 Correct 148 ms 9128 KB Output is correct
90 Correct 169 ms 9180 KB Output is correct
91 Correct 151 ms 9176 KB Output is correct
92 Correct 153 ms 9164 KB Output is correct
93 Correct 153 ms 9212 KB Output is correct
94 Correct 158 ms 9208 KB Output is correct
95 Correct 158 ms 9188 KB Output is correct
96 Correct 152 ms 9192 KB Output is correct
97 Correct 114 ms 10040 KB Output is correct
98 Correct 133 ms 9900 KB Output is correct
99 Correct 146 ms 10036 KB Output is correct
100 Correct 110 ms 9996 KB Output is correct
101 Correct 111 ms 9948 KB Output is correct
102 Correct 111 ms 9908 KB Output is correct
103 Correct 119 ms 10048 KB Output is correct
104 Correct 120 ms 9920 KB Output is correct
105 Correct 118 ms 9972 KB Output is correct
106 Correct 118 ms 9920 KB Output is correct