답안 #912425

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912425 2024-01-19T12:50:07 Z Pragmatism Wish (LMIO19_noras) C++17
100 / 100
536 ms 30120 KB
//Bismillahir-Rahmanir-Rahim

#include <bits/stdc++.h>
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("O1,O2,O3,Ofast,unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,sse4.1,sse4.2,popcnt,avx,avx2")

#define pb push_back
#define pii pair <int, int>
#define pll pair <long long, long long>
#define pld pair <long double, long double>
#define ll long long
#define ld long double
#define x first
#define y second
#define all(v) v.begin(),v.end()
#define sz(s) (int)s.size()
#define skip continue
#define bpop(x) (ll)__builtin_popcountll(x)

using namespace std;

const int N = 1e6 + 7;
const int K = 400;
const int maxA = 1e7 + 7;
const int inf = 1e9 + 7;
const ll INF = 1e18 + 7;
const ll MOD = 998244353;
const ld eps = 1e-9;

pii dir[] = {{0, 1}, {1, 0}, {0, -1}, {-1, 0}};

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define int long long

int n, Rad;
pii a[N], cur[N], slope[N];
ld f(int i, int t) {
    pii p = {a[i].x + slope[i].x * t, a[i].y + slope[i].y * t};
    return sqrt(1.0L * p.x * p.x + 1.0L * p.y * p.y);
}
int t[4 * N], z[4 * N];
void push(int v, int tl, int tr) {
    if (z[v] == 0)return;
    t[v]++;
    if (tl != tr)z[v * 2] = 1, z[v * 2 + 1] = 1;
    z[v] = 0;
}
void update(int v, int tl, int tr, int l, int r) {
    push(v, tl, tr);
    if (tr < l || tl > r)return;
    if (tl >= l && tr <= r) {
        z[v] = 1;
        push(v, tl, tr);
        return;
    }
    int mid = (tl + tr) / 2;
    update(v * 2, tl, mid, l, r), update(v * 2 + 1, mid + 1, tr, l, r);
    t[v] = max(t[v * 2], t[v * 2 + 1]);
}
int scan[N];
vector <pii> qs;
void sozhmi() {
    vector <int> v;
    for (auto p : qs)v.pb(p.x), v.pb(p.y);
    sort(all(v));
    map <int, int> id;
    int last = 0, pos = 0;
    for (auto x : v) {
        if (x == last)skip;
        id[x] = ++pos, last = x;
    }
    for (auto &p : qs)p.x = id[p.x], p.y = id[p.y];
}
void solve() {
    cin >> n >> Rad;
    for (int i = 1;i <= n;i++)cin >> a[i].x >> a[i].y >> slope[i].x >> slope[i].y, slope[i].x -= a[i].x, slope[i].y -= a[i].y, cur[i] = a[i];
    for (int i = 1;i <= n;i++) {
        int l = 0, r = 1e9 + 7, T = l;
        while (r - l >= 5) {
            int mid1 = l + (r - l) / 3, mid2 = r - (r - l) / 3;
            if (f(i, mid1) > f(i, mid2))l = mid1;
            else r = mid2;
        }
        for (int t = l;t <= r;t++) {
            if (f(i, t) < f(i, T))T = t;
        }
        if (f(i, T) > 1.0L * Rad)skip;
        int L = T, R = T;
        l = -1, r = T;
        while (l + 1 < r) {
            int mid = (l + r) / 2;
            if (f(i, mid) <= 1.0L * Rad) {
                //cout << i << ' ' << mid << ':' << f(i, mid) << "<=" << Rad << '\n';
                r = mid;
            }
            else l = mid;
        }
        L = r;
        l = T, r = 1e9 + 7;
        while (l + 1 < r) {
            int mid = (l + r) / 2;
            if (f(i, mid) <= 1.0L * Rad)l = mid;
            else r = mid;
        }
        R = l;
        L++, R++;
        qs.pb({L, R});
        //cout << i << ':' << T << ' ' << L << ' ' << R << '\n';
        //update(1, 1, n, L, R);
        //scan[L]++, scan[R + 1]--;
    }
    sozhmi();
    for (auto p : qs)scan[p.x]++, scan[p.y + 1]--;
    int ans = 0;
    for (int i = 1;i < N;i++)scan[i] += scan[i - 1], ans = max(ans, scan[i]);
    cout << ans;
    //int ans = 0;
    //cout << ans;
}
signed main() {
    //srand(time(NULL));
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    //freopen("tests.in", "r", stdin);
    //freopen("milkorder.out", "w", stdout);
    int test = 1;
    //cin >> test;
    for (int t = 1;t <= test;t++) {
        //cout << "Case " << t << ": ";
        solve();
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14424 KB Output is correct
2 Correct 7 ms 14428 KB Output is correct
3 Correct 9 ms 14364 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14428 KB Output is correct
6 Correct 9 ms 14424 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 7 ms 14428 KB Output is correct
9 Correct 8 ms 14428 KB Output is correct
10 Correct 7 ms 14212 KB Output is correct
11 Correct 8 ms 14228 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 7 ms 14424 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 11 ms 14428 KB Output is correct
17 Correct 10 ms 14424 KB Output is correct
18 Correct 10 ms 14428 KB Output is correct
19 Correct 10 ms 14428 KB Output is correct
20 Correct 10 ms 14476 KB Output is correct
21 Correct 9 ms 14424 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14424 KB Output is correct
2 Correct 7 ms 14428 KB Output is correct
3 Correct 9 ms 14364 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14428 KB Output is correct
6 Correct 9 ms 14424 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 7 ms 14428 KB Output is correct
9 Correct 8 ms 14428 KB Output is correct
10 Correct 7 ms 14212 KB Output is correct
11 Correct 8 ms 14228 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 7 ms 14424 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 11 ms 14428 KB Output is correct
17 Correct 10 ms 14424 KB Output is correct
18 Correct 10 ms 14428 KB Output is correct
19 Correct 10 ms 14428 KB Output is correct
20 Correct 10 ms 14476 KB Output is correct
21 Correct 9 ms 14424 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
23 Correct 203 ms 22120 KB Output is correct
24 Correct 205 ms 22120 KB Output is correct
25 Correct 201 ms 22120 KB Output is correct
26 Correct 207 ms 22640 KB Output is correct
27 Correct 178 ms 21340 KB Output is correct
28 Correct 199 ms 21996 KB Output is correct
29 Correct 201 ms 22076 KB Output is correct
30 Correct 209 ms 22000 KB Output is correct
31 Correct 204 ms 21896 KB Output is correct
32 Correct 239 ms 22120 KB Output is correct
33 Correct 239 ms 22124 KB Output is correct
34 Correct 240 ms 22636 KB Output is correct
35 Correct 242 ms 21988 KB Output is correct
36 Correct 244 ms 22032 KB Output is correct
37 Correct 198 ms 21588 KB Output is correct
38 Correct 197 ms 21596 KB Output is correct
39 Correct 189 ms 21396 KB Output is correct
40 Correct 191 ms 21372 KB Output is correct
41 Correct 187 ms 21464 KB Output is correct
42 Correct 188 ms 21916 KB Output is correct
43 Correct 520 ms 28900 KB Output is correct
44 Correct 513 ms 29160 KB Output is correct
45 Correct 513 ms 29744 KB Output is correct
46 Correct 514 ms 28832 KB Output is correct
47 Correct 515 ms 30120 KB Output is correct
48 Correct 471 ms 27652 KB Output is correct
49 Correct 469 ms 28268 KB Output is correct
50 Correct 468 ms 28644 KB Output is correct
51 Correct 466 ms 27828 KB Output is correct
52 Correct 470 ms 27788 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14424 KB Output is correct
2 Correct 7 ms 14428 KB Output is correct
3 Correct 9 ms 14364 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14428 KB Output is correct
6 Correct 9 ms 14424 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 7 ms 14428 KB Output is correct
9 Correct 8 ms 14428 KB Output is correct
10 Correct 7 ms 14212 KB Output is correct
11 Correct 8 ms 14228 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 7 ms 14424 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 11 ms 14428 KB Output is correct
17 Correct 10 ms 14424 KB Output is correct
18 Correct 10 ms 14428 KB Output is correct
19 Correct 10 ms 14428 KB Output is correct
20 Correct 10 ms 14476 KB Output is correct
21 Correct 9 ms 14424 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
23 Correct 7 ms 14428 KB Output is correct
24 Correct 9 ms 14428 KB Output is correct
25 Correct 10 ms 14336 KB Output is correct
26 Correct 10 ms 14424 KB Output is correct
27 Correct 9 ms 14428 KB Output is correct
28 Correct 9 ms 14424 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14424 KB Output is correct
2 Correct 7 ms 14428 KB Output is correct
3 Correct 9 ms 14364 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14428 KB Output is correct
6 Correct 9 ms 14424 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 7 ms 14428 KB Output is correct
9 Correct 8 ms 14428 KB Output is correct
10 Correct 7 ms 14212 KB Output is correct
11 Correct 8 ms 14228 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 7 ms 14424 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 11 ms 14428 KB Output is correct
17 Correct 10 ms 14424 KB Output is correct
18 Correct 10 ms 14428 KB Output is correct
19 Correct 10 ms 14428 KB Output is correct
20 Correct 10 ms 14476 KB Output is correct
21 Correct 9 ms 14424 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
23 Correct 203 ms 22120 KB Output is correct
24 Correct 205 ms 22120 KB Output is correct
25 Correct 201 ms 22120 KB Output is correct
26 Correct 207 ms 22640 KB Output is correct
27 Correct 178 ms 21340 KB Output is correct
28 Correct 199 ms 21996 KB Output is correct
29 Correct 201 ms 22076 KB Output is correct
30 Correct 209 ms 22000 KB Output is correct
31 Correct 204 ms 21896 KB Output is correct
32 Correct 239 ms 22120 KB Output is correct
33 Correct 239 ms 22124 KB Output is correct
34 Correct 240 ms 22636 KB Output is correct
35 Correct 242 ms 21988 KB Output is correct
36 Correct 244 ms 22032 KB Output is correct
37 Correct 198 ms 21588 KB Output is correct
38 Correct 197 ms 21596 KB Output is correct
39 Correct 189 ms 21396 KB Output is correct
40 Correct 191 ms 21372 KB Output is correct
41 Correct 187 ms 21464 KB Output is correct
42 Correct 188 ms 21916 KB Output is correct
43 Correct 520 ms 28900 KB Output is correct
44 Correct 513 ms 29160 KB Output is correct
45 Correct 513 ms 29744 KB Output is correct
46 Correct 514 ms 28832 KB Output is correct
47 Correct 515 ms 30120 KB Output is correct
48 Correct 471 ms 27652 KB Output is correct
49 Correct 469 ms 28268 KB Output is correct
50 Correct 468 ms 28644 KB Output is correct
51 Correct 466 ms 27828 KB Output is correct
52 Correct 470 ms 27788 KB Output is correct
53 Correct 7 ms 14428 KB Output is correct
54 Correct 9 ms 14428 KB Output is correct
55 Correct 10 ms 14336 KB Output is correct
56 Correct 10 ms 14424 KB Output is correct
57 Correct 9 ms 14428 KB Output is correct
58 Correct 9 ms 14424 KB Output is correct
59 Correct 202 ms 22116 KB Output is correct
60 Correct 182 ms 21448 KB Output is correct
61 Correct 183 ms 21396 KB Output is correct
62 Correct 185 ms 21448 KB Output is correct
63 Correct 197 ms 21632 KB Output is correct
64 Correct 199 ms 21568 KB Output is correct
65 Correct 197 ms 21644 KB Output is correct
66 Correct 198 ms 21616 KB Output is correct
67 Correct 202 ms 21792 KB Output is correct
68 Correct 242 ms 22220 KB Output is correct
69 Correct 243 ms 22016 KB Output is correct
70 Correct 244 ms 22064 KB Output is correct
71 Correct 244 ms 21992 KB Output is correct
72 Correct 243 ms 22116 KB Output is correct
73 Correct 194 ms 21668 KB Output is correct
74 Correct 202 ms 21556 KB Output is correct
75 Correct 207 ms 21920 KB Output is correct
76 Correct 190 ms 21520 KB Output is correct
77 Correct 491 ms 28516 KB Output is correct
78 Correct 486 ms 29128 KB Output is correct
79 Correct 486 ms 29596 KB Output is correct
80 Correct 487 ms 28508 KB Output is correct
81 Correct 490 ms 29440 KB Output is correct
82 Correct 479 ms 28040 KB Output is correct
83 Correct 477 ms 27704 KB Output is correct
84 Correct 483 ms 28192 KB Output is correct
85 Correct 490 ms 27612 KB Output is correct
86 Correct 536 ms 28568 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 7 ms 14424 KB Output is correct
2 Correct 7 ms 14428 KB Output is correct
3 Correct 9 ms 14364 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14428 KB Output is correct
6 Correct 9 ms 14424 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 7 ms 14428 KB Output is correct
9 Correct 8 ms 14428 KB Output is correct
10 Correct 7 ms 14212 KB Output is correct
11 Correct 8 ms 14228 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 7 ms 14424 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14428 KB Output is correct
16 Correct 11 ms 14428 KB Output is correct
17 Correct 10 ms 14424 KB Output is correct
18 Correct 10 ms 14428 KB Output is correct
19 Correct 10 ms 14428 KB Output is correct
20 Correct 10 ms 14476 KB Output is correct
21 Correct 9 ms 14424 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
23 Correct 203 ms 22120 KB Output is correct
24 Correct 205 ms 22120 KB Output is correct
25 Correct 201 ms 22120 KB Output is correct
26 Correct 207 ms 22640 KB Output is correct
27 Correct 178 ms 21340 KB Output is correct
28 Correct 199 ms 21996 KB Output is correct
29 Correct 201 ms 22076 KB Output is correct
30 Correct 209 ms 22000 KB Output is correct
31 Correct 204 ms 21896 KB Output is correct
32 Correct 239 ms 22120 KB Output is correct
33 Correct 239 ms 22124 KB Output is correct
34 Correct 240 ms 22636 KB Output is correct
35 Correct 242 ms 21988 KB Output is correct
36 Correct 244 ms 22032 KB Output is correct
37 Correct 198 ms 21588 KB Output is correct
38 Correct 197 ms 21596 KB Output is correct
39 Correct 189 ms 21396 KB Output is correct
40 Correct 191 ms 21372 KB Output is correct
41 Correct 187 ms 21464 KB Output is correct
42 Correct 188 ms 21916 KB Output is correct
43 Correct 520 ms 28900 KB Output is correct
44 Correct 513 ms 29160 KB Output is correct
45 Correct 513 ms 29744 KB Output is correct
46 Correct 514 ms 28832 KB Output is correct
47 Correct 515 ms 30120 KB Output is correct
48 Correct 471 ms 27652 KB Output is correct
49 Correct 469 ms 28268 KB Output is correct
50 Correct 468 ms 28644 KB Output is correct
51 Correct 466 ms 27828 KB Output is correct
52 Correct 470 ms 27788 KB Output is correct
53 Correct 202 ms 22116 KB Output is correct
54 Correct 182 ms 21448 KB Output is correct
55 Correct 183 ms 21396 KB Output is correct
56 Correct 185 ms 21448 KB Output is correct
57 Correct 197 ms 21632 KB Output is correct
58 Correct 199 ms 21568 KB Output is correct
59 Correct 197 ms 21644 KB Output is correct
60 Correct 198 ms 21616 KB Output is correct
61 Correct 202 ms 21792 KB Output is correct
62 Correct 242 ms 22220 KB Output is correct
63 Correct 243 ms 22016 KB Output is correct
64 Correct 244 ms 22064 KB Output is correct
65 Correct 244 ms 21992 KB Output is correct
66 Correct 243 ms 22116 KB Output is correct
67 Correct 194 ms 21668 KB Output is correct
68 Correct 202 ms 21556 KB Output is correct
69 Correct 207 ms 21920 KB Output is correct
70 Correct 190 ms 21520 KB Output is correct
71 Correct 491 ms 28516 KB Output is correct
72 Correct 486 ms 29128 KB Output is correct
73 Correct 486 ms 29596 KB Output is correct
74 Correct 487 ms 28508 KB Output is correct
75 Correct 490 ms 29440 KB Output is correct
76 Correct 479 ms 28040 KB Output is correct
77 Correct 477 ms 27704 KB Output is correct
78 Correct 483 ms 28192 KB Output is correct
79 Correct 490 ms 27612 KB Output is correct
80 Correct 536 ms 28568 KB Output is correct
81 Correct 7 ms 14428 KB Output is correct
82 Correct 9 ms 14428 KB Output is correct
83 Correct 10 ms 14336 KB Output is correct
84 Correct 10 ms 14424 KB Output is correct
85 Correct 9 ms 14428 KB Output is correct
86 Correct 9 ms 14424 KB Output is correct
87 Correct 235 ms 26072 KB Output is correct
88 Correct 229 ms 25500 KB Output is correct
89 Correct 222 ms 24476 KB Output is correct
90 Correct 221 ms 23300 KB Output is correct
91 Correct 213 ms 22628 KB Output is correct
92 Correct 233 ms 26144 KB Output is correct
93 Correct 233 ms 26252 KB Output is correct
94 Correct 239 ms 26092 KB Output is correct
95 Correct 233 ms 26232 KB Output is correct
96 Correct 234 ms 26252 KB Output is correct
97 Correct 206 ms 22124 KB Output is correct
98 Correct 209 ms 22312 KB Output is correct
99 Correct 207 ms 22124 KB Output is correct
100 Correct 206 ms 21988 KB Output is correct
101 Correct 211 ms 21988 KB Output is correct
102 Correct 206 ms 22120 KB Output is correct
103 Correct 207 ms 22380 KB Output is correct
104 Correct 209 ms 22072 KB Output is correct
105 Correct 210 ms 22128 KB Output is correct
106 Correct 209 ms 22248 KB Output is correct