Submission #955899

# Submission time Handle Problem Language Result Execution time Memory
955899 2024-03-31T16:25:21 Z DAleksa Curtains (NOI23_curtains) C++17
100 / 100
926 ms 69812 KB
#include <bits/stdc++.h>

using namespace std;

struct query {
    int l, r;
    bool ans;
};

const int N = 5e5 + 10, inf = 1e9;
int n, m, q;
vector<int> segments[N];
query all[N];
vector<int> qs[N];
int st[4 * N];
int lzy[4 * N];

void propagate(int index) {
    if(2 * index + 1 < 4 * N && lzy[index] != 0) {
        st[2 * index] = max(st[2 * index], lzy[index]);
        lzy[2 * index] = max(lzy[2 * index], lzy[index]);
        st[2 * index + 1] = max(st[2 * index + 1], lzy[index]);
        lzy[2 * index + 1] = max(lzy[2 * index + 1], lzy[index]);
        lzy[index] = 0;
    }
}

void update(int index, int l, int r, int L, int R, int val) {
    if(l > r || r < L || R < l) return;
    if(L <= l && r <= R) {
        st[index] = max(st[index], val);
        lzy[index] = max(lzy[index], val);
        return;
    }
    propagate(index);
    int mid = (l + r) / 2;
    update(2 * index, l, mid, L, R, val);
    update(2 * index + 1, mid + 1, r, L, R, val);
    st[index] = min(st[2 * index], st[2 * index + 1]);
}

int get(int index, int l, int r, int L, int R) {
    if(l > r || r < L || R < l) return inf;
    if(L <= l && r <= R) return st[index];
    propagate(index);
    int mid = (l + r) / 2;
    return min(get(2 * index, l, mid, L, R), get(2 * index + 1, mid + 1, r, L, R));
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    for(int i = 0; i < 4 * N; i++) st[i] = 0;
    cin >> n >> m >> q;
    for(int i = 0; i < m; i++) {
        int l, r;
        cin >> l >> r;
        segments[r].push_back(l);
    }
    for(int i = 0; i < q; i++) {
        cin >> all[i].l >> all[i].r;
        qs[all[i].r].push_back(i);
    }
    for(int r = 1; r <= n; r++) {
        for(int l : segments[r]) update(1, 1, n, l, r, l);
        for(int ind : qs[r]) {
            int l = all[ind].l;
//            cout << l << " " << r << ": " << get(1, 1, n, l, r) << "\n";
            if(get(1, 1, n, l, r) == l) all[ind].ans = true;
            else all[ind].ans = false;
        }
    }
    for(int i = 0; i < q; i++) {
        if(all[i].ans) cout << "YES\n";
        else cout << "NO\n";
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35164 KB Output is correct
2 Correct 7 ms 35024 KB Output is correct
3 Correct 9 ms 34908 KB Output is correct
4 Correct 8 ms 34908 KB Output is correct
5 Correct 8 ms 34908 KB Output is correct
6 Correct 8 ms 34904 KB Output is correct
7 Correct 9 ms 35164 KB Output is correct
8 Correct 8 ms 34904 KB Output is correct
9 Correct 8 ms 35012 KB Output is correct
10 Correct 9 ms 34908 KB Output is correct
11 Correct 8 ms 34908 KB Output is correct
12 Correct 8 ms 34904 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35164 KB Output is correct
2 Correct 7 ms 35024 KB Output is correct
3 Correct 9 ms 34908 KB Output is correct
4 Correct 8 ms 34908 KB Output is correct
5 Correct 8 ms 34908 KB Output is correct
6 Correct 8 ms 34904 KB Output is correct
7 Correct 9 ms 35164 KB Output is correct
8 Correct 8 ms 34904 KB Output is correct
9 Correct 8 ms 35012 KB Output is correct
10 Correct 9 ms 34908 KB Output is correct
11 Correct 8 ms 34908 KB Output is correct
12 Correct 8 ms 34904 KB Output is correct
13 Correct 10 ms 35164 KB Output is correct
14 Correct 9 ms 34908 KB Output is correct
15 Correct 10 ms 34908 KB Output is correct
16 Correct 10 ms 34984 KB Output is correct
17 Correct 9 ms 34908 KB Output is correct
18 Correct 11 ms 34908 KB Output is correct
19 Correct 9 ms 34904 KB Output is correct
20 Correct 9 ms 35160 KB Output is correct
21 Correct 9 ms 34908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35164 KB Output is correct
2 Correct 7 ms 35024 KB Output is correct
3 Correct 9 ms 34908 KB Output is correct
4 Correct 8 ms 34908 KB Output is correct
5 Correct 8 ms 34908 KB Output is correct
6 Correct 8 ms 34904 KB Output is correct
7 Correct 9 ms 35164 KB Output is correct
8 Correct 8 ms 34904 KB Output is correct
9 Correct 8 ms 35012 KB Output is correct
10 Correct 9 ms 34908 KB Output is correct
11 Correct 8 ms 34908 KB Output is correct
12 Correct 8 ms 34904 KB Output is correct
13 Correct 10 ms 35164 KB Output is correct
14 Correct 9 ms 34908 KB Output is correct
15 Correct 10 ms 34908 KB Output is correct
16 Correct 10 ms 34984 KB Output is correct
17 Correct 9 ms 34908 KB Output is correct
18 Correct 11 ms 34908 KB Output is correct
19 Correct 9 ms 34904 KB Output is correct
20 Correct 9 ms 35160 KB Output is correct
21 Correct 9 ms 34908 KB Output is correct
22 Correct 169 ms 43756 KB Output is correct
23 Correct 172 ms 44224 KB Output is correct
24 Correct 243 ms 44880 KB Output is correct
25 Correct 341 ms 47032 KB Output is correct
26 Correct 171 ms 44092 KB Output is correct
27 Correct 351 ms 47000 KB Output is correct
28 Correct 337 ms 46980 KB Output is correct
29 Correct 160 ms 43620 KB Output is correct
30 Correct 108 ms 44176 KB Output is correct
31 Correct 127 ms 44480 KB Output is correct
32 Correct 286 ms 47228 KB Output is correct
33 Correct 118 ms 44292 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 34904 KB Output is correct
2 Correct 8 ms 34908 KB Output is correct
3 Correct 8 ms 34908 KB Output is correct
4 Correct 8 ms 34908 KB Output is correct
5 Correct 9 ms 34908 KB Output is correct
6 Correct 9 ms 35160 KB Output is correct
7 Correct 9 ms 34908 KB Output is correct
8 Correct 110 ms 44248 KB Output is correct
9 Correct 129 ms 44492 KB Output is correct
10 Correct 281 ms 47248 KB Output is correct
11 Correct 110 ms 44372 KB Output is correct
12 Correct 115 ms 41300 KB Output is correct
13 Correct 106 ms 41168 KB Output is correct
14 Correct 87 ms 41296 KB Output is correct
15 Correct 97 ms 40936 KB Output is correct
16 Correct 83 ms 41296 KB Output is correct
17 Correct 82 ms 40900 KB Output is correct
18 Correct 769 ms 69268 KB Output is correct
19 Correct 736 ms 69472 KB Output is correct
20 Correct 610 ms 69812 KB Output is correct
21 Correct 582 ms 69264 KB Output is correct
22 Correct 602 ms 68436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35164 KB Output is correct
2 Correct 7 ms 35024 KB Output is correct
3 Correct 9 ms 34908 KB Output is correct
4 Correct 8 ms 34908 KB Output is correct
5 Correct 8 ms 34908 KB Output is correct
6 Correct 8 ms 34904 KB Output is correct
7 Correct 9 ms 35164 KB Output is correct
8 Correct 8 ms 34904 KB Output is correct
9 Correct 8 ms 35012 KB Output is correct
10 Correct 9 ms 34908 KB Output is correct
11 Correct 8 ms 34908 KB Output is correct
12 Correct 8 ms 34904 KB Output is correct
13 Correct 10 ms 35164 KB Output is correct
14 Correct 9 ms 34908 KB Output is correct
15 Correct 10 ms 34908 KB Output is correct
16 Correct 10 ms 34984 KB Output is correct
17 Correct 9 ms 34908 KB Output is correct
18 Correct 11 ms 34908 KB Output is correct
19 Correct 9 ms 34904 KB Output is correct
20 Correct 9 ms 35160 KB Output is correct
21 Correct 9 ms 34908 KB Output is correct
22 Correct 93 ms 36948 KB Output is correct
23 Correct 96 ms 36908 KB Output is correct
24 Correct 136 ms 39764 KB Output is correct
25 Correct 132 ms 39832 KB Output is correct
26 Correct 100 ms 40728 KB Output is correct
27 Correct 104 ms 41108 KB Output is correct
28 Correct 106 ms 39380 KB Output is correct
29 Correct 98 ms 40272 KB Output is correct
30 Correct 125 ms 39764 KB Output is correct
31 Correct 132 ms 39924 KB Output is correct
32 Correct 128 ms 40464 KB Output is correct
33 Correct 105 ms 40528 KB Output is correct
34 Correct 146 ms 39164 KB Output is correct
35 Correct 114 ms 39628 KB Output is correct
36 Correct 114 ms 40276 KB Output is correct
37 Correct 107 ms 41216 KB Output is correct
38 Correct 108 ms 41296 KB Output is correct
39 Correct 92 ms 41200 KB Output is correct
40 Correct 84 ms 40972 KB Output is correct
41 Correct 91 ms 41100 KB Output is correct
42 Correct 84 ms 40784 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 35164 KB Output is correct
2 Correct 7 ms 35024 KB Output is correct
3 Correct 9 ms 34908 KB Output is correct
4 Correct 8 ms 34908 KB Output is correct
5 Correct 8 ms 34908 KB Output is correct
6 Correct 8 ms 34904 KB Output is correct
7 Correct 9 ms 35164 KB Output is correct
8 Correct 8 ms 34904 KB Output is correct
9 Correct 8 ms 35012 KB Output is correct
10 Correct 9 ms 34908 KB Output is correct
11 Correct 8 ms 34908 KB Output is correct
12 Correct 8 ms 34904 KB Output is correct
13 Correct 10 ms 35164 KB Output is correct
14 Correct 9 ms 34908 KB Output is correct
15 Correct 10 ms 34908 KB Output is correct
16 Correct 10 ms 34984 KB Output is correct
17 Correct 9 ms 34908 KB Output is correct
18 Correct 11 ms 34908 KB Output is correct
19 Correct 9 ms 34904 KB Output is correct
20 Correct 9 ms 35160 KB Output is correct
21 Correct 9 ms 34908 KB Output is correct
22 Correct 169 ms 43756 KB Output is correct
23 Correct 172 ms 44224 KB Output is correct
24 Correct 243 ms 44880 KB Output is correct
25 Correct 341 ms 47032 KB Output is correct
26 Correct 171 ms 44092 KB Output is correct
27 Correct 351 ms 47000 KB Output is correct
28 Correct 337 ms 46980 KB Output is correct
29 Correct 160 ms 43620 KB Output is correct
30 Correct 108 ms 44176 KB Output is correct
31 Correct 127 ms 44480 KB Output is correct
32 Correct 286 ms 47228 KB Output is correct
33 Correct 118 ms 44292 KB Output is correct
34 Correct 9 ms 34904 KB Output is correct
35 Correct 8 ms 34908 KB Output is correct
36 Correct 8 ms 34908 KB Output is correct
37 Correct 8 ms 34908 KB Output is correct
38 Correct 9 ms 34908 KB Output is correct
39 Correct 9 ms 35160 KB Output is correct
40 Correct 9 ms 34908 KB Output is correct
41 Correct 110 ms 44248 KB Output is correct
42 Correct 129 ms 44492 KB Output is correct
43 Correct 281 ms 47248 KB Output is correct
44 Correct 110 ms 44372 KB Output is correct
45 Correct 115 ms 41300 KB Output is correct
46 Correct 106 ms 41168 KB Output is correct
47 Correct 87 ms 41296 KB Output is correct
48 Correct 97 ms 40936 KB Output is correct
49 Correct 83 ms 41296 KB Output is correct
50 Correct 82 ms 40900 KB Output is correct
51 Correct 769 ms 69268 KB Output is correct
52 Correct 736 ms 69472 KB Output is correct
53 Correct 610 ms 69812 KB Output is correct
54 Correct 582 ms 69264 KB Output is correct
55 Correct 602 ms 68436 KB Output is correct
56 Correct 93 ms 36948 KB Output is correct
57 Correct 96 ms 36908 KB Output is correct
58 Correct 136 ms 39764 KB Output is correct
59 Correct 132 ms 39832 KB Output is correct
60 Correct 100 ms 40728 KB Output is correct
61 Correct 104 ms 41108 KB Output is correct
62 Correct 106 ms 39380 KB Output is correct
63 Correct 98 ms 40272 KB Output is correct
64 Correct 125 ms 39764 KB Output is correct
65 Correct 132 ms 39924 KB Output is correct
66 Correct 128 ms 40464 KB Output is correct
67 Correct 105 ms 40528 KB Output is correct
68 Correct 146 ms 39164 KB Output is correct
69 Correct 114 ms 39628 KB Output is correct
70 Correct 114 ms 40276 KB Output is correct
71 Correct 107 ms 41216 KB Output is correct
72 Correct 108 ms 41296 KB Output is correct
73 Correct 92 ms 41200 KB Output is correct
74 Correct 84 ms 40972 KB Output is correct
75 Correct 91 ms 41100 KB Output is correct
76 Correct 84 ms 40784 KB Output is correct
77 Correct 863 ms 62748 KB Output is correct
78 Correct 926 ms 62628 KB Output is correct
79 Correct 656 ms 67920 KB Output is correct
80 Correct 719 ms 68996 KB Output is correct
81 Correct 693 ms 67128 KB Output is correct
82 Correct 666 ms 67224 KB Output is correct
83 Correct 909 ms 62692 KB Output is correct
84 Correct 891 ms 62768 KB Output is correct
85 Correct 802 ms 64684 KB Output is correct
86 Correct 738 ms 60628 KB Output is correct
87 Correct 765 ms 61208 KB Output is correct
88 Correct 698 ms 67032 KB Output is correct