답안 #912424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
912424 2024-01-19T12:49:13 Z vjudge1 Wish (LMIO19_noras) C++17
100 / 100
522 ms 29928 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 8 ms 14428 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14304 KB Output is correct
6 Correct 9 ms 14428 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 8 ms 14428 KB Output is correct
9 Correct 7 ms 14424 KB Output is correct
10 Correct 7 ms 14424 KB Output is correct
11 Correct 7 ms 14424 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 8 ms 14428 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14424 KB Output is correct
16 Correct 9 ms 14428 KB Output is correct
17 Correct 9 ms 14296 KB Output is correct
18 Correct 9 ms 14428 KB Output is correct
19 Correct 9 ms 14296 KB Output is correct
20 Correct 9 ms 14428 KB Output is correct
21 Correct 9 ms 14272 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 8 ms 14428 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14304 KB Output is correct
6 Correct 9 ms 14428 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 8 ms 14428 KB Output is correct
9 Correct 7 ms 14424 KB Output is correct
10 Correct 7 ms 14424 KB Output is correct
11 Correct 7 ms 14424 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 8 ms 14428 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14424 KB Output is correct
16 Correct 9 ms 14428 KB Output is correct
17 Correct 9 ms 14296 KB Output is correct
18 Correct 9 ms 14428 KB Output is correct
19 Correct 9 ms 14296 KB Output is correct
20 Correct 9 ms 14428 KB Output is correct
21 Correct 9 ms 14272 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
23 Correct 204 ms 22004 KB Output is correct
24 Correct 202 ms 22120 KB Output is correct
25 Correct 210 ms 22376 KB Output is correct
26 Correct 202 ms 21980 KB Output is correct
27 Correct 179 ms 21316 KB Output is correct
28 Correct 200 ms 21964 KB Output is correct
29 Correct 208 ms 21996 KB Output is correct
30 Correct 204 ms 21904 KB Output is correct
31 Correct 204 ms 21920 KB Output is correct
32 Correct 238 ms 22120 KB Output is correct
33 Correct 241 ms 22120 KB Output is correct
34 Correct 246 ms 22140 KB Output is correct
35 Correct 242 ms 22116 KB Output is correct
36 Correct 238 ms 22096 KB Output is correct
37 Correct 204 ms 21712 KB Output is correct
38 Correct 196 ms 21596 KB Output is correct
39 Correct 189 ms 21496 KB Output is correct
40 Correct 191 ms 21428 KB Output is correct
41 Correct 189 ms 21380 KB Output is correct
42 Correct 193 ms 21432 KB Output is correct
43 Correct 519 ms 28928 KB Output is correct
44 Correct 516 ms 29264 KB Output is correct
45 Correct 512 ms 29180 KB Output is correct
46 Correct 522 ms 29576 KB Output is correct
47 Correct 521 ms 29928 KB Output is correct
48 Correct 476 ms 27732 KB Output is correct
49 Correct 470 ms 27840 KB Output is correct
50 Correct 468 ms 28616 KB Output is correct
51 Correct 472 ms 28752 KB Output is correct
52 Correct 472 ms 29004 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 8 ms 14428 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14304 KB Output is correct
6 Correct 9 ms 14428 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 8 ms 14428 KB Output is correct
9 Correct 7 ms 14424 KB Output is correct
10 Correct 7 ms 14424 KB Output is correct
11 Correct 7 ms 14424 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 8 ms 14428 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14424 KB Output is correct
16 Correct 9 ms 14428 KB Output is correct
17 Correct 9 ms 14296 KB Output is correct
18 Correct 9 ms 14428 KB Output is correct
19 Correct 9 ms 14296 KB Output is correct
20 Correct 9 ms 14428 KB Output is correct
21 Correct 9 ms 14272 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
23 Correct 7 ms 14424 KB Output is correct
24 Correct 10 ms 14624 KB Output is correct
25 Correct 10 ms 14424 KB Output is correct
26 Correct 11 ms 14444 KB Output is correct
27 Correct 9 ms 14428 KB Output is correct
28 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 8 ms 14428 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14304 KB Output is correct
6 Correct 9 ms 14428 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 8 ms 14428 KB Output is correct
9 Correct 7 ms 14424 KB Output is correct
10 Correct 7 ms 14424 KB Output is correct
11 Correct 7 ms 14424 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 8 ms 14428 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14424 KB Output is correct
16 Correct 9 ms 14428 KB Output is correct
17 Correct 9 ms 14296 KB Output is correct
18 Correct 9 ms 14428 KB Output is correct
19 Correct 9 ms 14296 KB Output is correct
20 Correct 9 ms 14428 KB Output is correct
21 Correct 9 ms 14272 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
23 Correct 204 ms 22004 KB Output is correct
24 Correct 202 ms 22120 KB Output is correct
25 Correct 210 ms 22376 KB Output is correct
26 Correct 202 ms 21980 KB Output is correct
27 Correct 179 ms 21316 KB Output is correct
28 Correct 200 ms 21964 KB Output is correct
29 Correct 208 ms 21996 KB Output is correct
30 Correct 204 ms 21904 KB Output is correct
31 Correct 204 ms 21920 KB Output is correct
32 Correct 238 ms 22120 KB Output is correct
33 Correct 241 ms 22120 KB Output is correct
34 Correct 246 ms 22140 KB Output is correct
35 Correct 242 ms 22116 KB Output is correct
36 Correct 238 ms 22096 KB Output is correct
37 Correct 204 ms 21712 KB Output is correct
38 Correct 196 ms 21596 KB Output is correct
39 Correct 189 ms 21496 KB Output is correct
40 Correct 191 ms 21428 KB Output is correct
41 Correct 189 ms 21380 KB Output is correct
42 Correct 193 ms 21432 KB Output is correct
43 Correct 519 ms 28928 KB Output is correct
44 Correct 516 ms 29264 KB Output is correct
45 Correct 512 ms 29180 KB Output is correct
46 Correct 522 ms 29576 KB Output is correct
47 Correct 521 ms 29928 KB Output is correct
48 Correct 476 ms 27732 KB Output is correct
49 Correct 470 ms 27840 KB Output is correct
50 Correct 468 ms 28616 KB Output is correct
51 Correct 472 ms 28752 KB Output is correct
52 Correct 472 ms 29004 KB Output is correct
53 Correct 7 ms 14424 KB Output is correct
54 Correct 10 ms 14624 KB Output is correct
55 Correct 10 ms 14424 KB Output is correct
56 Correct 11 ms 14444 KB Output is correct
57 Correct 9 ms 14428 KB Output is correct
58 Correct 9 ms 14428 KB Output is correct
59 Correct 208 ms 22172 KB Output is correct
60 Correct 184 ms 21368 KB Output is correct
61 Correct 191 ms 21308 KB Output is correct
62 Correct 186 ms 21416 KB Output is correct
63 Correct 198 ms 21724 KB Output is correct
64 Correct 196 ms 21740 KB Output is correct
65 Correct 201 ms 21640 KB Output is correct
66 Correct 197 ms 21816 KB Output is correct
67 Correct 196 ms 21648 KB Output is correct
68 Correct 245 ms 22104 KB Output is correct
69 Correct 243 ms 22208 KB Output is correct
70 Correct 242 ms 22120 KB Output is correct
71 Correct 242 ms 22124 KB Output is correct
72 Correct 248 ms 22020 KB Output is correct
73 Correct 193 ms 21668 KB Output is correct
74 Correct 201 ms 21748 KB Output is correct
75 Correct 207 ms 21920 KB Output is correct
76 Correct 191 ms 21536 KB Output is correct
77 Correct 493 ms 29128 KB Output is correct
78 Correct 495 ms 29188 KB Output is correct
79 Correct 490 ms 28760 KB Output is correct
80 Correct 505 ms 28788 KB Output is correct
81 Correct 489 ms 28856 KB Output is correct
82 Correct 490 ms 27908 KB Output is correct
83 Correct 477 ms 27728 KB Output is correct
84 Correct 485 ms 28644 KB Output is correct
85 Correct 483 ms 27784 KB Output is correct
86 Correct 478 ms 27796 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 8 ms 14428 KB Output is correct
4 Correct 9 ms 14428 KB Output is correct
5 Correct 9 ms 14304 KB Output is correct
6 Correct 9 ms 14428 KB Output is correct
7 Correct 9 ms 14424 KB Output is correct
8 Correct 8 ms 14428 KB Output is correct
9 Correct 7 ms 14424 KB Output is correct
10 Correct 7 ms 14424 KB Output is correct
11 Correct 7 ms 14424 KB Output is correct
12 Correct 7 ms 14428 KB Output is correct
13 Correct 8 ms 14428 KB Output is correct
14 Correct 10 ms 14428 KB Output is correct
15 Correct 10 ms 14424 KB Output is correct
16 Correct 9 ms 14428 KB Output is correct
17 Correct 9 ms 14296 KB Output is correct
18 Correct 9 ms 14428 KB Output is correct
19 Correct 9 ms 14296 KB Output is correct
20 Correct 9 ms 14428 KB Output is correct
21 Correct 9 ms 14272 KB Output is correct
22 Correct 9 ms 14428 KB Output is correct
23 Correct 204 ms 22004 KB Output is correct
24 Correct 202 ms 22120 KB Output is correct
25 Correct 210 ms 22376 KB Output is correct
26 Correct 202 ms 21980 KB Output is correct
27 Correct 179 ms 21316 KB Output is correct
28 Correct 200 ms 21964 KB Output is correct
29 Correct 208 ms 21996 KB Output is correct
30 Correct 204 ms 21904 KB Output is correct
31 Correct 204 ms 21920 KB Output is correct
32 Correct 238 ms 22120 KB Output is correct
33 Correct 241 ms 22120 KB Output is correct
34 Correct 246 ms 22140 KB Output is correct
35 Correct 242 ms 22116 KB Output is correct
36 Correct 238 ms 22096 KB Output is correct
37 Correct 204 ms 21712 KB Output is correct
38 Correct 196 ms 21596 KB Output is correct
39 Correct 189 ms 21496 KB Output is correct
40 Correct 191 ms 21428 KB Output is correct
41 Correct 189 ms 21380 KB Output is correct
42 Correct 193 ms 21432 KB Output is correct
43 Correct 519 ms 28928 KB Output is correct
44 Correct 516 ms 29264 KB Output is correct
45 Correct 512 ms 29180 KB Output is correct
46 Correct 522 ms 29576 KB Output is correct
47 Correct 521 ms 29928 KB Output is correct
48 Correct 476 ms 27732 KB Output is correct
49 Correct 470 ms 27840 KB Output is correct
50 Correct 468 ms 28616 KB Output is correct
51 Correct 472 ms 28752 KB Output is correct
52 Correct 472 ms 29004 KB Output is correct
53 Correct 208 ms 22172 KB Output is correct
54 Correct 184 ms 21368 KB Output is correct
55 Correct 191 ms 21308 KB Output is correct
56 Correct 186 ms 21416 KB Output is correct
57 Correct 198 ms 21724 KB Output is correct
58 Correct 196 ms 21740 KB Output is correct
59 Correct 201 ms 21640 KB Output is correct
60 Correct 197 ms 21816 KB Output is correct
61 Correct 196 ms 21648 KB Output is correct
62 Correct 245 ms 22104 KB Output is correct
63 Correct 243 ms 22208 KB Output is correct
64 Correct 242 ms 22120 KB Output is correct
65 Correct 242 ms 22124 KB Output is correct
66 Correct 248 ms 22020 KB Output is correct
67 Correct 193 ms 21668 KB Output is correct
68 Correct 201 ms 21748 KB Output is correct
69 Correct 207 ms 21920 KB Output is correct
70 Correct 191 ms 21536 KB Output is correct
71 Correct 493 ms 29128 KB Output is correct
72 Correct 495 ms 29188 KB Output is correct
73 Correct 490 ms 28760 KB Output is correct
74 Correct 505 ms 28788 KB Output is correct
75 Correct 489 ms 28856 KB Output is correct
76 Correct 490 ms 27908 KB Output is correct
77 Correct 477 ms 27728 KB Output is correct
78 Correct 485 ms 28644 KB Output is correct
79 Correct 483 ms 27784 KB Output is correct
80 Correct 478 ms 27796 KB Output is correct
81 Correct 7 ms 14424 KB Output is correct
82 Correct 10 ms 14624 KB Output is correct
83 Correct 10 ms 14424 KB Output is correct
84 Correct 11 ms 14444 KB Output is correct
85 Correct 9 ms 14428 KB Output is correct
86 Correct 9 ms 14428 KB Output is correct
87 Correct 232 ms 26052 KB Output is correct
88 Correct 233 ms 25464 KB Output is correct
89 Correct 221 ms 24460 KB Output is correct
90 Correct 215 ms 23308 KB Output is correct
91 Correct 213 ms 22812 KB Output is correct
92 Correct 231 ms 26192 KB Output is correct
93 Correct 240 ms 26140 KB Output is correct
94 Correct 234 ms 26192 KB Output is correct
95 Correct 231 ms 26136 KB Output is correct
96 Correct 234 ms 26388 KB Output is correct
97 Correct 208 ms 22196 KB Output is correct
98 Correct 207 ms 22208 KB Output is correct
99 Correct 206 ms 22120 KB Output is correct
100 Correct 207 ms 22136 KB Output is correct
101 Correct 216 ms 22888 KB Output is correct
102 Correct 206 ms 22232 KB Output is correct
103 Correct 208 ms 22124 KB Output is correct
104 Correct 213 ms 22280 KB Output is correct
105 Correct 210 ms 22120 KB Output is correct
106 Correct 210 ms 22104 KB Output is correct