Submission #886806

# Submission time Handle Problem Language Result Execution time Memory
886806 2023-12-13T02:09:13 Z thangdz2k7 Curtains (NOI23_curtains) C++17
100 / 100
767 ms 78516 KB
#include <bits/stdc++.h>
#define F first
#define S second
#define ii pair <int, int>
#define pb push_back

using namespace std;

const int N = 5e5 + 5;

int n, m, q;
int s[N], e[N], ans[N];
vector <int> event[N], query[N];

int Min[4 * N], lazy[4 * N];

void down(int s){
    for (int i = 2 * s; i <= 2 * s + 1; ++ i){
        lazy[i] = max(lazy[i], lazy[s]);
        Min[i] = max(Min[i], lazy[s]);
    }
    lazy[s] = 0;
}

void update(int s, int l, int r, int u, int v, int val){
    if (u <= l && r <= v) {
        Min[s] = max(Min[s], val), lazy[s] = max(lazy[s], val);
        return;
    }
    int mid = l + r >> 1;
    down(s);
    if (mid >= u) update(2 * s, l, mid, u, v, val);
    if (mid + 1 <= v) update(2 * s + 1, mid + 1, r, u, v, val);
    Min[s] = min(Min[2 * s], Min[2 * s + 1]);
}

int get(int s, int l, int r, int u, int v){
    if (r < u or l > v) return 1e9;
    if (u <= l && r <= v) return Min[s];
    down(s);
    int mid = l + r >> 1;
    return min(get(2 * s, l, mid, u, v), get(2 * s + 1, mid + 1, r, u, v));
}

void solve(){
    cin >> n >> m >> q;
    for (int i = 1; i <= m; ++ i){
        int l, r;
        cin >> l >> r;
        event[r].pb(l);
    }

    for (int i = 1; i <= q; ++ i){
        cin >> s[i] >> e[i];
        query[e[i]].pb(i);
    }

    for (int i = 1; i <= n; ++ i){
        for (int l : event[i]) update(1, 1, n, l, i, l);
        for (int k : query[i]){
            if (get(1, 1, n, s[k], i) >= s[k]) ans[k] = 1;
        }
    }

    for (int i = 1; i <= q; ++ i) if (ans[i]) cout << "YES" << '\n';
    else cout << "NO" << '\n';
}

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

Compilation message

curtains.cpp: In function 'void update(int, int, int, int, int, int)':
curtains.cpp:30:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   30 |     int mid = l + r >> 1;
      |               ~~^~~
curtains.cpp: In function 'int get(int, int, int, int, int)':
curtains.cpp:41:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   41 |     int mid = l + r >> 1;
      |               ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29016 KB Output is correct
2 Correct 6 ms 29188 KB Output is correct
3 Correct 6 ms 29172 KB Output is correct
4 Correct 6 ms 29020 KB Output is correct
5 Correct 7 ms 29016 KB Output is correct
6 Correct 6 ms 29152 KB Output is correct
7 Correct 6 ms 29020 KB Output is correct
8 Correct 7 ms 29020 KB Output is correct
9 Correct 7 ms 29188 KB Output is correct
10 Correct 6 ms 29020 KB Output is correct
11 Correct 6 ms 29016 KB Output is correct
12 Correct 6 ms 29020 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29016 KB Output is correct
2 Correct 6 ms 29188 KB Output is correct
3 Correct 6 ms 29172 KB Output is correct
4 Correct 6 ms 29020 KB Output is correct
5 Correct 7 ms 29016 KB Output is correct
6 Correct 6 ms 29152 KB Output is correct
7 Correct 6 ms 29020 KB Output is correct
8 Correct 7 ms 29020 KB Output is correct
9 Correct 7 ms 29188 KB Output is correct
10 Correct 6 ms 29020 KB Output is correct
11 Correct 6 ms 29016 KB Output is correct
12 Correct 6 ms 29020 KB Output is correct
13 Correct 7 ms 29272 KB Output is correct
14 Correct 7 ms 29148 KB Output is correct
15 Correct 7 ms 29276 KB Output is correct
16 Correct 7 ms 29272 KB Output is correct
17 Correct 7 ms 29276 KB Output is correct
18 Correct 7 ms 29276 KB Output is correct
19 Correct 7 ms 29380 KB Output is correct
20 Correct 9 ms 29272 KB Output is correct
21 Correct 8 ms 29356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29016 KB Output is correct
2 Correct 6 ms 29188 KB Output is correct
3 Correct 6 ms 29172 KB Output is correct
4 Correct 6 ms 29020 KB Output is correct
5 Correct 7 ms 29016 KB Output is correct
6 Correct 6 ms 29152 KB Output is correct
7 Correct 6 ms 29020 KB Output is correct
8 Correct 7 ms 29020 KB Output is correct
9 Correct 7 ms 29188 KB Output is correct
10 Correct 6 ms 29020 KB Output is correct
11 Correct 6 ms 29016 KB Output is correct
12 Correct 6 ms 29020 KB Output is correct
13 Correct 7 ms 29272 KB Output is correct
14 Correct 7 ms 29148 KB Output is correct
15 Correct 7 ms 29276 KB Output is correct
16 Correct 7 ms 29272 KB Output is correct
17 Correct 7 ms 29276 KB Output is correct
18 Correct 7 ms 29276 KB Output is correct
19 Correct 7 ms 29380 KB Output is correct
20 Correct 9 ms 29272 KB Output is correct
21 Correct 8 ms 29356 KB Output is correct
22 Correct 176 ms 39892 KB Output is correct
23 Correct 181 ms 40528 KB Output is correct
24 Correct 215 ms 42004 KB Output is correct
25 Correct 330 ms 47444 KB Output is correct
26 Correct 184 ms 40276 KB Output is correct
27 Correct 328 ms 47696 KB Output is correct
28 Correct 338 ms 47664 KB Output is correct
29 Correct 176 ms 39484 KB Output is correct
30 Correct 125 ms 39252 KB Output is correct
31 Correct 140 ms 39808 KB Output is correct
32 Correct 271 ms 46280 KB Output is correct
33 Correct 123 ms 39248 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 29020 KB Output is correct
2 Correct 6 ms 29144 KB Output is correct
3 Correct 6 ms 29108 KB Output is correct
4 Correct 6 ms 29020 KB Output is correct
5 Correct 7 ms 29368 KB Output is correct
6 Correct 8 ms 29276 KB Output is correct
7 Correct 9 ms 29148 KB Output is correct
8 Correct 124 ms 39172 KB Output is correct
9 Correct 149 ms 39844 KB Output is correct
10 Correct 273 ms 46416 KB Output is correct
11 Correct 126 ms 39244 KB Output is correct
12 Correct 100 ms 38540 KB Output is correct
13 Correct 101 ms 38424 KB Output is correct
14 Correct 81 ms 38648 KB Output is correct
15 Correct 81 ms 38084 KB Output is correct
16 Correct 81 ms 38480 KB Output is correct
17 Correct 86 ms 38228 KB Output is correct
18 Correct 680 ms 76372 KB Output is correct
19 Correct 667 ms 76372 KB Output is correct
20 Correct 515 ms 76884 KB Output is correct
21 Correct 521 ms 76228 KB Output is correct
22 Correct 538 ms 75696 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29016 KB Output is correct
2 Correct 6 ms 29188 KB Output is correct
3 Correct 6 ms 29172 KB Output is correct
4 Correct 6 ms 29020 KB Output is correct
5 Correct 7 ms 29016 KB Output is correct
6 Correct 6 ms 29152 KB Output is correct
7 Correct 6 ms 29020 KB Output is correct
8 Correct 7 ms 29020 KB Output is correct
9 Correct 7 ms 29188 KB Output is correct
10 Correct 6 ms 29020 KB Output is correct
11 Correct 6 ms 29016 KB Output is correct
12 Correct 6 ms 29020 KB Output is correct
13 Correct 7 ms 29272 KB Output is correct
14 Correct 7 ms 29148 KB Output is correct
15 Correct 7 ms 29276 KB Output is correct
16 Correct 7 ms 29272 KB Output is correct
17 Correct 7 ms 29276 KB Output is correct
18 Correct 7 ms 29276 KB Output is correct
19 Correct 7 ms 29380 KB Output is correct
20 Correct 9 ms 29272 KB Output is correct
21 Correct 8 ms 29356 KB Output is correct
22 Correct 88 ms 33360 KB Output is correct
23 Correct 88 ms 33296 KB Output is correct
24 Correct 119 ms 37456 KB Output is correct
25 Correct 122 ms 37460 KB Output is correct
26 Correct 101 ms 38740 KB Output is correct
27 Correct 102 ms 38748 KB Output is correct
28 Correct 81 ms 36640 KB Output is correct
29 Correct 106 ms 38228 KB Output is correct
30 Correct 119 ms 37460 KB Output is correct
31 Correct 130 ms 37968 KB Output is correct
32 Correct 107 ms 37892 KB Output is correct
33 Correct 103 ms 38228 KB Output is correct
34 Correct 110 ms 36764 KB Output is correct
35 Correct 114 ms 37224 KB Output is correct
36 Correct 110 ms 37968 KB Output is correct
37 Correct 102 ms 38556 KB Output is correct
38 Correct 106 ms 38408 KB Output is correct
39 Correct 81 ms 38564 KB Output is correct
40 Correct 82 ms 38224 KB Output is correct
41 Correct 92 ms 38616 KB Output is correct
42 Correct 86 ms 38328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 9 ms 29016 KB Output is correct
2 Correct 6 ms 29188 KB Output is correct
3 Correct 6 ms 29172 KB Output is correct
4 Correct 6 ms 29020 KB Output is correct
5 Correct 7 ms 29016 KB Output is correct
6 Correct 6 ms 29152 KB Output is correct
7 Correct 6 ms 29020 KB Output is correct
8 Correct 7 ms 29020 KB Output is correct
9 Correct 7 ms 29188 KB Output is correct
10 Correct 6 ms 29020 KB Output is correct
11 Correct 6 ms 29016 KB Output is correct
12 Correct 6 ms 29020 KB Output is correct
13 Correct 7 ms 29272 KB Output is correct
14 Correct 7 ms 29148 KB Output is correct
15 Correct 7 ms 29276 KB Output is correct
16 Correct 7 ms 29272 KB Output is correct
17 Correct 7 ms 29276 KB Output is correct
18 Correct 7 ms 29276 KB Output is correct
19 Correct 7 ms 29380 KB Output is correct
20 Correct 9 ms 29272 KB Output is correct
21 Correct 8 ms 29356 KB Output is correct
22 Correct 176 ms 39892 KB Output is correct
23 Correct 181 ms 40528 KB Output is correct
24 Correct 215 ms 42004 KB Output is correct
25 Correct 330 ms 47444 KB Output is correct
26 Correct 184 ms 40276 KB Output is correct
27 Correct 328 ms 47696 KB Output is correct
28 Correct 338 ms 47664 KB Output is correct
29 Correct 176 ms 39484 KB Output is correct
30 Correct 125 ms 39252 KB Output is correct
31 Correct 140 ms 39808 KB Output is correct
32 Correct 271 ms 46280 KB Output is correct
33 Correct 123 ms 39248 KB Output is correct
34 Correct 6 ms 29020 KB Output is correct
35 Correct 6 ms 29144 KB Output is correct
36 Correct 6 ms 29108 KB Output is correct
37 Correct 6 ms 29020 KB Output is correct
38 Correct 7 ms 29368 KB Output is correct
39 Correct 8 ms 29276 KB Output is correct
40 Correct 9 ms 29148 KB Output is correct
41 Correct 124 ms 39172 KB Output is correct
42 Correct 149 ms 39844 KB Output is correct
43 Correct 273 ms 46416 KB Output is correct
44 Correct 126 ms 39244 KB Output is correct
45 Correct 100 ms 38540 KB Output is correct
46 Correct 101 ms 38424 KB Output is correct
47 Correct 81 ms 38648 KB Output is correct
48 Correct 81 ms 38084 KB Output is correct
49 Correct 81 ms 38480 KB Output is correct
50 Correct 86 ms 38228 KB Output is correct
51 Correct 680 ms 76372 KB Output is correct
52 Correct 667 ms 76372 KB Output is correct
53 Correct 515 ms 76884 KB Output is correct
54 Correct 521 ms 76228 KB Output is correct
55 Correct 538 ms 75696 KB Output is correct
56 Correct 88 ms 33360 KB Output is correct
57 Correct 88 ms 33296 KB Output is correct
58 Correct 119 ms 37456 KB Output is correct
59 Correct 122 ms 37460 KB Output is correct
60 Correct 101 ms 38740 KB Output is correct
61 Correct 102 ms 38748 KB Output is correct
62 Correct 81 ms 36640 KB Output is correct
63 Correct 106 ms 38228 KB Output is correct
64 Correct 119 ms 37460 KB Output is correct
65 Correct 130 ms 37968 KB Output is correct
66 Correct 107 ms 37892 KB Output is correct
67 Correct 103 ms 38228 KB Output is correct
68 Correct 110 ms 36764 KB Output is correct
69 Correct 114 ms 37224 KB Output is correct
70 Correct 110 ms 37968 KB Output is correct
71 Correct 102 ms 38556 KB Output is correct
72 Correct 106 ms 38408 KB Output is correct
73 Correct 81 ms 38564 KB Output is correct
74 Correct 82 ms 38224 KB Output is correct
75 Correct 92 ms 38616 KB Output is correct
76 Correct 86 ms 38328 KB Output is correct
77 Correct 757 ms 71772 KB Output is correct
78 Correct 760 ms 71756 KB Output is correct
79 Correct 647 ms 78212 KB Output is correct
80 Correct 671 ms 78516 KB Output is correct
81 Correct 632 ms 75964 KB Output is correct
82 Correct 655 ms 77128 KB Output is correct
83 Correct 767 ms 72152 KB Output is correct
84 Correct 757 ms 71764 KB Output is correct
85 Correct 718 ms 73628 KB Output is correct
86 Correct 683 ms 69460 KB Output is correct
87 Correct 692 ms 69196 KB Output is correct
88 Correct 668 ms 75912 KB Output is correct