답안 #998843

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
998843 2024-06-14T17:46:12 Z LOLOLO Curtains (NOI23_curtains) C++17
100 / 100
688 ms 74576 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
#define           f     first
#define           s     second
#define           pb    push_back
#define           ep    emplace
#define           eb    emplace_back
#define           lb    lower_bound
#define           ub    upper_bound
#define       all(x)    x.begin(), x.end()
#define      rall(x)    x.rbegin(), x.rend()
#define   uniquev(v)    sort(all(v)), (v).resize(unique(all(v)) - (v).begin())
#define     mem(f,x)    memset(f , x , sizeof(f))
#define        sz(x)    (ll)(x).size()
#define  __lcm(a, b)    (1ll * ((a) / __gcd((a), (b))) * (b))
#define          mxx    *max_element
#define          mnn    *min_element
#define    cntbit(x)    __builtin_popcountll(x)
#define       len(x)    (int)(x.length())
 
const int N = 5e5 + 10;
int st[N * 4], laz[N * 4];

void push(int id) {
    int t = laz[id];
    laz[id * 2] = max(laz[id * 2], t);
    laz[id * 2 + 1] = max(laz[id * 2 + 1], t);
    st[id * 2] = max(st[id * 2], t);
    st[id * 2 + 1] = max(st[id * 2 + 1], t); 
}

void upd(int id, int l, int r, int u, int v, int c) {
    if (l > v || r < u)
        return;

    if (l >= u && r <= v) {
        laz[id] = max(laz[id], c);
        st[id] = max(st[id], c);
        return;
    }

    push(id);
    int m = (l + r) / 2;
    upd(id * 2, l, m, u, v, c);
    upd(id * 2 + 1, m + 1, r, u, v, c);
    st[id] = min(st[id * 2], st[id * 2 + 1]);
}

int get(int id, int l, int r, int u, int v) {
    if (l > v || r < u)
        return 1e9;

    if (l >= u && r <= v)
        return st[id];

    push(id);
    int m = (l + r) / 2;
    return min(get(id * 2, l, m, u, v), get(id * 2 + 1, m + 1, r, u, v));
}

vector <int> add[N];
vector <pair <int, int>> ask[N];
int ans[N];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int n, m, q;
    cin >> n >> m >> q;

    for (int i = 1; i <= m; i++) {
        int l, r;
        cin >> l >> r;
        add[r].pb(l);
    }

    for (int i = 1; i <= q; i++) {
        int l, r;
        cin >> l >> r;
        ask[r].pb({l, i});
    }

    for (int i = 1; i <= n; i++) {
        for (auto x : add[i]) {
            upd(1, 1, n, x, i, x);
        }

        for (auto x : ask[i]) {
            ans[x.s] = get(1, 1, n, x.f, i) >= x.f;
        }
    }

    for (int i = 1; i <= q; i++) {
        if (ans[i]) {
            cout << "YES\n";
        } else {
            cout << "NO\n";
        }
    }
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 26972 KB Output is correct
2 Correct 4 ms 27032 KB Output is correct
3 Correct 4 ms 26972 KB Output is correct
4 Correct 4 ms 26968 KB Output is correct
5 Correct 4 ms 27140 KB Output is correct
6 Correct 4 ms 26972 KB Output is correct
7 Correct 4 ms 27156 KB Output is correct
8 Correct 4 ms 26972 KB Output is correct
9 Correct 4 ms 26972 KB Output is correct
10 Correct 4 ms 27076 KB Output is correct
11 Correct 4 ms 26972 KB Output is correct
12 Correct 4 ms 26972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 26972 KB Output is correct
2 Correct 4 ms 27032 KB Output is correct
3 Correct 4 ms 26972 KB Output is correct
4 Correct 4 ms 26968 KB Output is correct
5 Correct 4 ms 27140 KB Output is correct
6 Correct 4 ms 26972 KB Output is correct
7 Correct 4 ms 27156 KB Output is correct
8 Correct 4 ms 26972 KB Output is correct
9 Correct 4 ms 26972 KB Output is correct
10 Correct 4 ms 27076 KB Output is correct
11 Correct 4 ms 26972 KB Output is correct
12 Correct 4 ms 26972 KB Output is correct
13 Correct 5 ms 27228 KB Output is correct
14 Correct 5 ms 27228 KB Output is correct
15 Correct 5 ms 27280 KB Output is correct
16 Correct 5 ms 27228 KB Output is correct
17 Correct 6 ms 27228 KB Output is correct
18 Correct 5 ms 27228 KB Output is correct
19 Correct 5 ms 27228 KB Output is correct
20 Correct 5 ms 27228 KB Output is correct
21 Correct 5 ms 27088 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 26972 KB Output is correct
2 Correct 4 ms 27032 KB Output is correct
3 Correct 4 ms 26972 KB Output is correct
4 Correct 4 ms 26968 KB Output is correct
5 Correct 4 ms 27140 KB Output is correct
6 Correct 4 ms 26972 KB Output is correct
7 Correct 4 ms 27156 KB Output is correct
8 Correct 4 ms 26972 KB Output is correct
9 Correct 4 ms 26972 KB Output is correct
10 Correct 4 ms 27076 KB Output is correct
11 Correct 4 ms 26972 KB Output is correct
12 Correct 4 ms 26972 KB Output is correct
13 Correct 5 ms 27228 KB Output is correct
14 Correct 5 ms 27228 KB Output is correct
15 Correct 5 ms 27280 KB Output is correct
16 Correct 5 ms 27228 KB Output is correct
17 Correct 6 ms 27228 KB Output is correct
18 Correct 5 ms 27228 KB Output is correct
19 Correct 5 ms 27228 KB Output is correct
20 Correct 5 ms 27228 KB Output is correct
21 Correct 5 ms 27088 KB Output is correct
22 Correct 154 ms 39416 KB Output is correct
23 Correct 158 ms 39760 KB Output is correct
24 Correct 178 ms 41176 KB Output is correct
25 Correct 293 ms 46928 KB Output is correct
26 Correct 158 ms 39512 KB Output is correct
27 Correct 306 ms 46884 KB Output is correct
28 Correct 297 ms 47052 KB Output is correct
29 Correct 142 ms 38484 KB Output is correct
30 Correct 101 ms 38740 KB Output is correct
31 Correct 114 ms 39416 KB Output is correct
32 Correct 239 ms 46160 KB Output is correct
33 Correct 112 ms 38740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 26972 KB Output is correct
2 Correct 4 ms 27108 KB Output is correct
3 Correct 4 ms 26968 KB Output is correct
4 Correct 5 ms 26972 KB Output is correct
5 Correct 5 ms 27228 KB Output is correct
6 Correct 5 ms 27088 KB Output is correct
7 Correct 5 ms 27228 KB Output is correct
8 Correct 98 ms 38660 KB Output is correct
9 Correct 116 ms 39504 KB Output is correct
10 Correct 244 ms 46120 KB Output is correct
11 Correct 98 ms 38736 KB Output is correct
12 Correct 88 ms 35352 KB Output is correct
13 Correct 86 ms 35412 KB Output is correct
14 Correct 76 ms 35572 KB Output is correct
15 Correct 69 ms 35152 KB Output is correct
16 Correct 67 ms 35452 KB Output is correct
17 Correct 74 ms 35156 KB Output is correct
18 Correct 543 ms 71140 KB Output is correct
19 Correct 555 ms 71252 KB Output is correct
20 Correct 456 ms 71956 KB Output is correct
21 Correct 436 ms 71252 KB Output is correct
22 Correct 431 ms 70228 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 26972 KB Output is correct
2 Correct 4 ms 27032 KB Output is correct
3 Correct 4 ms 26972 KB Output is correct
4 Correct 4 ms 26968 KB Output is correct
5 Correct 4 ms 27140 KB Output is correct
6 Correct 4 ms 26972 KB Output is correct
7 Correct 4 ms 27156 KB Output is correct
8 Correct 4 ms 26972 KB Output is correct
9 Correct 4 ms 26972 KB Output is correct
10 Correct 4 ms 27076 KB Output is correct
11 Correct 4 ms 26972 KB Output is correct
12 Correct 4 ms 26972 KB Output is correct
13 Correct 5 ms 27228 KB Output is correct
14 Correct 5 ms 27228 KB Output is correct
15 Correct 5 ms 27280 KB Output is correct
16 Correct 5 ms 27228 KB Output is correct
17 Correct 6 ms 27228 KB Output is correct
18 Correct 5 ms 27228 KB Output is correct
19 Correct 5 ms 27228 KB Output is correct
20 Correct 5 ms 27228 KB Output is correct
21 Correct 5 ms 27088 KB Output is correct
22 Correct 82 ms 31824 KB Output is correct
23 Correct 82 ms 31744 KB Output is correct
24 Correct 105 ms 34708 KB Output is correct
25 Correct 106 ms 34640 KB Output is correct
26 Correct 87 ms 35920 KB Output is correct
27 Correct 90 ms 36060 KB Output is correct
28 Correct 70 ms 33640 KB Output is correct
29 Correct 84 ms 35412 KB Output is correct
30 Correct 105 ms 34700 KB Output is correct
31 Correct 104 ms 34640 KB Output is correct
32 Correct 94 ms 35160 KB Output is correct
33 Correct 99 ms 35412 KB Output is correct
34 Correct 112 ms 34028 KB Output is correct
35 Correct 97 ms 34384 KB Output is correct
36 Correct 95 ms 34900 KB Output is correct
37 Correct 85 ms 35428 KB Output is correct
38 Correct 87 ms 35372 KB Output is correct
39 Correct 85 ms 35664 KB Output is correct
40 Correct 68 ms 35076 KB Output is correct
41 Correct 73 ms 35436 KB Output is correct
42 Correct 69 ms 35256 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 26972 KB Output is correct
2 Correct 4 ms 27032 KB Output is correct
3 Correct 4 ms 26972 KB Output is correct
4 Correct 4 ms 26968 KB Output is correct
5 Correct 4 ms 27140 KB Output is correct
6 Correct 4 ms 26972 KB Output is correct
7 Correct 4 ms 27156 KB Output is correct
8 Correct 4 ms 26972 KB Output is correct
9 Correct 4 ms 26972 KB Output is correct
10 Correct 4 ms 27076 KB Output is correct
11 Correct 4 ms 26972 KB Output is correct
12 Correct 4 ms 26972 KB Output is correct
13 Correct 5 ms 27228 KB Output is correct
14 Correct 5 ms 27228 KB Output is correct
15 Correct 5 ms 27280 KB Output is correct
16 Correct 5 ms 27228 KB Output is correct
17 Correct 6 ms 27228 KB Output is correct
18 Correct 5 ms 27228 KB Output is correct
19 Correct 5 ms 27228 KB Output is correct
20 Correct 5 ms 27228 KB Output is correct
21 Correct 5 ms 27088 KB Output is correct
22 Correct 154 ms 39416 KB Output is correct
23 Correct 158 ms 39760 KB Output is correct
24 Correct 178 ms 41176 KB Output is correct
25 Correct 293 ms 46928 KB Output is correct
26 Correct 158 ms 39512 KB Output is correct
27 Correct 306 ms 46884 KB Output is correct
28 Correct 297 ms 47052 KB Output is correct
29 Correct 142 ms 38484 KB Output is correct
30 Correct 101 ms 38740 KB Output is correct
31 Correct 114 ms 39416 KB Output is correct
32 Correct 239 ms 46160 KB Output is correct
33 Correct 112 ms 38740 KB Output is correct
34 Correct 4 ms 26972 KB Output is correct
35 Correct 4 ms 27108 KB Output is correct
36 Correct 4 ms 26968 KB Output is correct
37 Correct 5 ms 26972 KB Output is correct
38 Correct 5 ms 27228 KB Output is correct
39 Correct 5 ms 27088 KB Output is correct
40 Correct 5 ms 27228 KB Output is correct
41 Correct 98 ms 38660 KB Output is correct
42 Correct 116 ms 39504 KB Output is correct
43 Correct 244 ms 46120 KB Output is correct
44 Correct 98 ms 38736 KB Output is correct
45 Correct 88 ms 35352 KB Output is correct
46 Correct 86 ms 35412 KB Output is correct
47 Correct 76 ms 35572 KB Output is correct
48 Correct 69 ms 35152 KB Output is correct
49 Correct 67 ms 35452 KB Output is correct
50 Correct 74 ms 35156 KB Output is correct
51 Correct 543 ms 71140 KB Output is correct
52 Correct 555 ms 71252 KB Output is correct
53 Correct 456 ms 71956 KB Output is correct
54 Correct 436 ms 71252 KB Output is correct
55 Correct 431 ms 70228 KB Output is correct
56 Correct 82 ms 31824 KB Output is correct
57 Correct 82 ms 31744 KB Output is correct
58 Correct 105 ms 34708 KB Output is correct
59 Correct 106 ms 34640 KB Output is correct
60 Correct 87 ms 35920 KB Output is correct
61 Correct 90 ms 36060 KB Output is correct
62 Correct 70 ms 33640 KB Output is correct
63 Correct 84 ms 35412 KB Output is correct
64 Correct 105 ms 34700 KB Output is correct
65 Correct 104 ms 34640 KB Output is correct
66 Correct 94 ms 35160 KB Output is correct
67 Correct 99 ms 35412 KB Output is correct
68 Correct 112 ms 34028 KB Output is correct
69 Correct 97 ms 34384 KB Output is correct
70 Correct 95 ms 34900 KB Output is correct
71 Correct 85 ms 35428 KB Output is correct
72 Correct 87 ms 35372 KB Output is correct
73 Correct 85 ms 35664 KB Output is correct
74 Correct 68 ms 35076 KB Output is correct
75 Correct 73 ms 35436 KB Output is correct
76 Correct 69 ms 35256 KB Output is correct
77 Correct 677 ms 67668 KB Output is correct
78 Correct 659 ms 67664 KB Output is correct
79 Correct 537 ms 74324 KB Output is correct
80 Correct 552 ms 74576 KB Output is correct
81 Correct 538 ms 72276 KB Output is correct
82 Correct 557 ms 73300 KB Output is correct
83 Correct 643 ms 67720 KB Output is correct
84 Correct 688 ms 67864 KB Output is correct
85 Correct 574 ms 69460 KB Output is correct
86 Correct 578 ms 65872 KB Output is correct
87 Correct 589 ms 65616 KB Output is correct
88 Correct 552 ms 72272 KB Output is correct