답안 #639186

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
639186 2022-09-08T22:06:47 Z Pietra Wish (LMIO19_noras) C++14
93 / 100
252 ms 11936 KB
#include<bits/stdc++.h>
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} ;
}


int 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(0, 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(0, 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 1 ms 212 KB Output is correct
3 Correct 2 ms 352 KB Output is correct
4 Correct 2 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 1 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 1 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 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 320 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 352 KB Output is correct
4 Correct 2 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 1 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 1 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 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 320 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 96 ms 5652 KB Output is correct
24 Correct 95 ms 5556 KB Output is correct
25 Correct 93 ms 5620 KB Output is correct
26 Correct 95 ms 5576 KB Output is correct
27 Correct 107 ms 4776 KB Output is correct
28 Correct 94 ms 5696 KB Output is correct
29 Correct 95 ms 5840 KB Output is correct
30 Correct 96 ms 5708 KB Output is correct
31 Correct 102 ms 5684 KB Output is correct
32 Correct 116 ms 5868 KB Output is correct
33 Correct 103 ms 5700 KB Output is correct
34 Correct 101 ms 5700 KB Output is correct
35 Correct 103 ms 5768 KB Output is correct
36 Correct 100 ms 5744 KB Output is correct
37 Correct 105 ms 4576 KB Output is correct
38 Correct 87 ms 4544 KB Output is correct
39 Correct 86 ms 4468 KB Output is correct
40 Correct 86 ms 4520 KB Output is correct
41 Correct 118 ms 4544 KB Output is correct
42 Correct 97 ms 4632 KB Output is correct
43 Correct 231 ms 11900 KB Output is correct
44 Correct 230 ms 11876 KB Output is correct
45 Correct 252 ms 11868 KB Output is correct
46 Correct 237 ms 11892 KB Output is correct
47 Correct 230 ms 11872 KB Output is correct
48 Correct 238 ms 11152 KB Output is correct
49 Correct 206 ms 11068 KB Output is correct
50 Correct 202 ms 11112 KB Output is correct
51 Correct 233 ms 11232 KB Output is correct
52 Correct 203 ms 11100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 352 KB Output is correct
4 Correct 2 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 1 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 1 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 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 320 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 1 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 2 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 1 ms 212 KB Output is correct
3 Correct 2 ms 352 KB Output is correct
4 Correct 2 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 1 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 1 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 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 320 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 96 ms 5652 KB Output is correct
24 Correct 95 ms 5556 KB Output is correct
25 Correct 93 ms 5620 KB Output is correct
26 Correct 95 ms 5576 KB Output is correct
27 Correct 107 ms 4776 KB Output is correct
28 Correct 94 ms 5696 KB Output is correct
29 Correct 95 ms 5840 KB Output is correct
30 Correct 96 ms 5708 KB Output is correct
31 Correct 102 ms 5684 KB Output is correct
32 Correct 116 ms 5868 KB Output is correct
33 Correct 103 ms 5700 KB Output is correct
34 Correct 101 ms 5700 KB Output is correct
35 Correct 103 ms 5768 KB Output is correct
36 Correct 100 ms 5744 KB Output is correct
37 Correct 105 ms 4576 KB Output is correct
38 Correct 87 ms 4544 KB Output is correct
39 Correct 86 ms 4468 KB Output is correct
40 Correct 86 ms 4520 KB Output is correct
41 Correct 118 ms 4544 KB Output is correct
42 Correct 97 ms 4632 KB Output is correct
43 Correct 231 ms 11900 KB Output is correct
44 Correct 230 ms 11876 KB Output is correct
45 Correct 252 ms 11868 KB Output is correct
46 Correct 237 ms 11892 KB Output is correct
47 Correct 230 ms 11872 KB Output is correct
48 Correct 238 ms 11152 KB Output is correct
49 Correct 206 ms 11068 KB Output is correct
50 Correct 202 ms 11112 KB Output is correct
51 Correct 233 ms 11232 KB Output is correct
52 Correct 203 ms 11100 KB Output is correct
53 Correct 1 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 2 ms 340 KB Output is correct
58 Correct 1 ms 340 KB Output is correct
59 Correct 88 ms 5596 KB Output is correct
60 Correct 107 ms 4984 KB Output is correct
61 Correct 108 ms 4936 KB Output is correct
62 Correct 105 ms 4920 KB Output is correct
63 Correct 116 ms 5108 KB Output is correct
64 Correct 111 ms 5036 KB Output is correct
65 Correct 119 ms 5064 KB Output is correct
66 Correct 109 ms 4984 KB Output is correct
67 Correct 112 ms 5152 KB Output is correct
68 Correct 114 ms 5824 KB Output is correct
69 Correct 116 ms 5800 KB Output is correct
70 Correct 112 ms 5912 KB Output is correct
71 Correct 113 ms 5860 KB Output is correct
72 Correct 115 ms 5944 KB Output is correct
73 Correct 88 ms 4540 KB Output is correct
74 Correct 94 ms 5508 KB Output is correct
75 Correct 92 ms 5556 KB Output is correct
76 Correct 101 ms 4648 KB Output is correct
77 Correct 233 ms 11800 KB Output is correct
78 Correct 237 ms 11772 KB Output is correct
79 Correct 235 ms 11888 KB Output is correct
80 Correct 229 ms 11936 KB Output is correct
81 Correct 230 ms 11804 KB Output is correct
82 Correct 215 ms 11404 KB Output is correct
83 Correct 220 ms 11324 KB Output is correct
84 Correct 215 ms 11344 KB Output is correct
85 Correct 215 ms 11324 KB Output is correct
86 Correct 219 ms 11392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 2 ms 352 KB Output is correct
4 Correct 2 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 1 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 1 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 2 ms 340 KB Output is correct
17 Correct 2 ms 340 KB Output is correct
18 Correct 2 ms 320 KB Output is correct
19 Correct 2 ms 340 KB Output is correct
20 Correct 2 ms 340 KB Output is correct
21 Correct 1 ms 320 KB Output is correct
22 Correct 2 ms 340 KB Output is correct
23 Correct 96 ms 5652 KB Output is correct
24 Correct 95 ms 5556 KB Output is correct
25 Correct 93 ms 5620 KB Output is correct
26 Correct 95 ms 5576 KB Output is correct
27 Correct 107 ms 4776 KB Output is correct
28 Correct 94 ms 5696 KB Output is correct
29 Correct 95 ms 5840 KB Output is correct
30 Correct 96 ms 5708 KB Output is correct
31 Correct 102 ms 5684 KB Output is correct
32 Correct 116 ms 5868 KB Output is correct
33 Correct 103 ms 5700 KB Output is correct
34 Correct 101 ms 5700 KB Output is correct
35 Correct 103 ms 5768 KB Output is correct
36 Correct 100 ms 5744 KB Output is correct
37 Correct 105 ms 4576 KB Output is correct
38 Correct 87 ms 4544 KB Output is correct
39 Correct 86 ms 4468 KB Output is correct
40 Correct 86 ms 4520 KB Output is correct
41 Correct 118 ms 4544 KB Output is correct
42 Correct 97 ms 4632 KB Output is correct
43 Correct 231 ms 11900 KB Output is correct
44 Correct 230 ms 11876 KB Output is correct
45 Correct 252 ms 11868 KB Output is correct
46 Correct 237 ms 11892 KB Output is correct
47 Correct 230 ms 11872 KB Output is correct
48 Correct 238 ms 11152 KB Output is correct
49 Correct 206 ms 11068 KB Output is correct
50 Correct 202 ms 11112 KB Output is correct
51 Correct 233 ms 11232 KB Output is correct
52 Correct 203 ms 11100 KB Output is correct
53 Correct 88 ms 5596 KB Output is correct
54 Correct 107 ms 4984 KB Output is correct
55 Correct 108 ms 4936 KB Output is correct
56 Correct 105 ms 4920 KB Output is correct
57 Correct 116 ms 5108 KB Output is correct
58 Correct 111 ms 5036 KB Output is correct
59 Correct 119 ms 5064 KB Output is correct
60 Correct 109 ms 4984 KB Output is correct
61 Correct 112 ms 5152 KB Output is correct
62 Correct 114 ms 5824 KB Output is correct
63 Correct 116 ms 5800 KB Output is correct
64 Correct 112 ms 5912 KB Output is correct
65 Correct 113 ms 5860 KB Output is correct
66 Correct 115 ms 5944 KB Output is correct
67 Correct 88 ms 4540 KB Output is correct
68 Correct 94 ms 5508 KB Output is correct
69 Correct 92 ms 5556 KB Output is correct
70 Correct 101 ms 4648 KB Output is correct
71 Correct 233 ms 11800 KB Output is correct
72 Correct 237 ms 11772 KB Output is correct
73 Correct 235 ms 11888 KB Output is correct
74 Correct 229 ms 11936 KB Output is correct
75 Correct 230 ms 11804 KB Output is correct
76 Correct 215 ms 11404 KB Output is correct
77 Correct 220 ms 11324 KB Output is correct
78 Correct 215 ms 11344 KB Output is correct
79 Correct 215 ms 11324 KB Output is correct
80 Correct 219 ms 11392 KB Output is correct
81 Correct 1 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 2 ms 340 KB Output is correct
86 Correct 1 ms 340 KB Output is correct
87 Incorrect 158 ms 7568 KB Output isn't correct
88 Halted 0 ms 0 KB -