Submission #930887

# Submission time Handle Problem Language Result Execution time Memory
930887 2024-02-20T15:12:04 Z adaawf Curtains (NOI23_curtains) C++17
100 / 100
870 ms 83096 KB
#include <iostream>
#include <vector>
#include <cstring>
using namespace std;
int t[2000005], tt[2000005], res[500005];
vector<int> g[500005];
vector<pair<int, int>> gg[500005];
void update(int v, int tl, int tr, int l, int r, int x) {
    if (l > r) return;
    if (tl == l && r == tr) {
        t[v] = min(t[v], x);
        tt[v] = min(tt[v], x);
        return;
    }
    int mid = (tl + tr) / 2;
    update(v * 2, tl, mid, l, min(r, mid), x);
    update(v * 2 + 1, mid + 1, tr, max(l, mid + 1), r, x);
    t[v] = min(max(t[v * 2], t[v * 2 + 1]), tt[v]);
}
int sum(int v, int tl, int tr, int l, int r) {
    if (l > r) return 1e9 + 1;
    if (tl == l && tr == r) {
        return t[v];
    }
    int mid = (tl + tr) / 2;
    int h = sum(v * 2, tl, mid, l, min(r, mid)), k = sum(v * 2 + 1, mid + 1, tr, max(l, mid + 1), r);
    if (h == 1e9 + 1) return min(k, tt[v]);
    if (k == 1e9 + 1) return min(h, tt[v]);
    return min(max(h, k), tt[v]);
}
int main() {
    ios::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 u, v;
        cin >> u >> v;
        g[u].push_back(v);
    }
    for (int i = 0; i < q; i++) {
        int u, v;
        cin >> u >> v;
        gg[u].push_back({v, i});
    }
    for (int i = 1; i <= n * 4; i++) t[i] = tt[i] = 1e9;
    for (int i = n; i >= 1; i--) {
        for (int w : g[i]) {
            update(1, 1, n, i, w, w);
        }
        for (auto w : gg[i]) {
            if (sum(1, 1, n, i, w.first) <= w.first) {
                res[w.second] = 1;
            }
        }
    }
    for (int i = 0; i < q; i++) {
        if (res[i] == 0) cout << "NO";
        else cout << "YES";
        cout << '\n';
    }
}
# Verdict Execution time Memory Grader output
1 Correct 11 ms 29272 KB Output is correct
2 Correct 9 ms 29272 KB Output is correct
3 Correct 9 ms 29276 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 8 ms 29276 KB Output is correct
6 Correct 7 ms 29276 KB Output is correct
7 Correct 7 ms 29384 KB Output is correct
8 Correct 7 ms 29272 KB Output is correct
9 Correct 8 ms 29276 KB Output is correct
10 Correct 8 ms 29276 KB Output is correct
11 Correct 7 ms 29272 KB Output is correct
12 Correct 8 ms 29272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 29272 KB Output is correct
2 Correct 9 ms 29272 KB Output is correct
3 Correct 9 ms 29276 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 8 ms 29276 KB Output is correct
6 Correct 7 ms 29276 KB Output is correct
7 Correct 7 ms 29384 KB Output is correct
8 Correct 7 ms 29272 KB Output is correct
9 Correct 8 ms 29276 KB Output is correct
10 Correct 8 ms 29276 KB Output is correct
11 Correct 7 ms 29272 KB Output is correct
12 Correct 8 ms 29272 KB Output is correct
13 Correct 10 ms 29276 KB Output is correct
14 Correct 10 ms 29312 KB Output is correct
15 Correct 11 ms 29384 KB Output is correct
16 Correct 9 ms 29276 KB Output is correct
17 Correct 9 ms 29272 KB Output is correct
18 Correct 11 ms 29320 KB Output is correct
19 Correct 10 ms 29476 KB Output is correct
20 Correct 8 ms 29272 KB Output is correct
21 Correct 10 ms 29508 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 29272 KB Output is correct
2 Correct 9 ms 29272 KB Output is correct
3 Correct 9 ms 29276 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 8 ms 29276 KB Output is correct
6 Correct 7 ms 29276 KB Output is correct
7 Correct 7 ms 29384 KB Output is correct
8 Correct 7 ms 29272 KB Output is correct
9 Correct 8 ms 29276 KB Output is correct
10 Correct 8 ms 29276 KB Output is correct
11 Correct 7 ms 29272 KB Output is correct
12 Correct 8 ms 29272 KB Output is correct
13 Correct 10 ms 29276 KB Output is correct
14 Correct 10 ms 29312 KB Output is correct
15 Correct 11 ms 29384 KB Output is correct
16 Correct 9 ms 29276 KB Output is correct
17 Correct 9 ms 29272 KB Output is correct
18 Correct 11 ms 29320 KB Output is correct
19 Correct 10 ms 29476 KB Output is correct
20 Correct 8 ms 29272 KB Output is correct
21 Correct 10 ms 29508 KB Output is correct
22 Correct 197 ms 41388 KB Output is correct
23 Correct 181 ms 41808 KB Output is correct
24 Correct 206 ms 43348 KB Output is correct
25 Correct 315 ms 48884 KB Output is correct
26 Correct 180 ms 41556 KB Output is correct
27 Correct 315 ms 48948 KB Output is correct
28 Correct 314 ms 48980 KB Output is correct
29 Correct 169 ms 41556 KB Output is correct
30 Correct 132 ms 38332 KB Output is correct
31 Correct 146 ms 39192 KB Output is correct
32 Correct 268 ms 45968 KB Output is correct
33 Correct 132 ms 38580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 8 ms 29272 KB Output is correct
2 Correct 7 ms 29276 KB Output is correct
3 Correct 7 ms 29276 KB Output is correct
4 Correct 8 ms 29276 KB Output is correct
5 Correct 8 ms 29276 KB Output is correct
6 Correct 9 ms 29272 KB Output is correct
7 Correct 8 ms 29276 KB Output is correct
8 Correct 132 ms 38436 KB Output is correct
9 Correct 144 ms 39188 KB Output is correct
10 Correct 271 ms 45944 KB Output is correct
11 Correct 130 ms 38524 KB Output is correct
12 Correct 93 ms 36548 KB Output is correct
13 Correct 93 ms 36292 KB Output is correct
14 Correct 78 ms 36500 KB Output is correct
15 Correct 76 ms 36308 KB Output is correct
16 Correct 77 ms 36300 KB Output is correct
17 Correct 79 ms 36456 KB Output is correct
18 Correct 539 ms 67008 KB Output is correct
19 Correct 510 ms 67224 KB Output is correct
20 Correct 441 ms 67772 KB Output is correct
21 Correct 427 ms 67920 KB Output is correct
22 Correct 422 ms 67776 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 29272 KB Output is correct
2 Correct 9 ms 29272 KB Output is correct
3 Correct 9 ms 29276 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 8 ms 29276 KB Output is correct
6 Correct 7 ms 29276 KB Output is correct
7 Correct 7 ms 29384 KB Output is correct
8 Correct 7 ms 29272 KB Output is correct
9 Correct 8 ms 29276 KB Output is correct
10 Correct 8 ms 29276 KB Output is correct
11 Correct 7 ms 29272 KB Output is correct
12 Correct 8 ms 29272 KB Output is correct
13 Correct 10 ms 29276 KB Output is correct
14 Correct 10 ms 29312 KB Output is correct
15 Correct 11 ms 29384 KB Output is correct
16 Correct 9 ms 29276 KB Output is correct
17 Correct 9 ms 29272 KB Output is correct
18 Correct 11 ms 29320 KB Output is correct
19 Correct 10 ms 29476 KB Output is correct
20 Correct 8 ms 29272 KB Output is correct
21 Correct 10 ms 29508 KB Output is correct
22 Correct 88 ms 33712 KB Output is correct
23 Correct 93 ms 33692 KB Output is correct
24 Correct 119 ms 37716 KB Output is correct
25 Correct 117 ms 37744 KB Output is correct
26 Correct 99 ms 39248 KB Output is correct
27 Correct 113 ms 39252 KB Output is correct
28 Correct 86 ms 36948 KB Output is correct
29 Correct 101 ms 38736 KB Output is correct
30 Correct 120 ms 37648 KB Output is correct
31 Correct 120 ms 37712 KB Output is correct
32 Correct 106 ms 37972 KB Output is correct
33 Correct 103 ms 38228 KB Output is correct
34 Correct 110 ms 37460 KB Output is correct
35 Correct 121 ms 37200 KB Output is correct
36 Correct 109 ms 37564 KB Output is correct
37 Correct 93 ms 36256 KB Output is correct
38 Correct 99 ms 36288 KB Output is correct
39 Correct 81 ms 36508 KB Output is correct
40 Correct 78 ms 36456 KB Output is correct
41 Correct 79 ms 36300 KB Output is correct
42 Correct 78 ms 36452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 11 ms 29272 KB Output is correct
2 Correct 9 ms 29272 KB Output is correct
3 Correct 9 ms 29276 KB Output is correct
4 Correct 7 ms 29276 KB Output is correct
5 Correct 8 ms 29276 KB Output is correct
6 Correct 7 ms 29276 KB Output is correct
7 Correct 7 ms 29384 KB Output is correct
8 Correct 7 ms 29272 KB Output is correct
9 Correct 8 ms 29276 KB Output is correct
10 Correct 8 ms 29276 KB Output is correct
11 Correct 7 ms 29272 KB Output is correct
12 Correct 8 ms 29272 KB Output is correct
13 Correct 10 ms 29276 KB Output is correct
14 Correct 10 ms 29312 KB Output is correct
15 Correct 11 ms 29384 KB Output is correct
16 Correct 9 ms 29276 KB Output is correct
17 Correct 9 ms 29272 KB Output is correct
18 Correct 11 ms 29320 KB Output is correct
19 Correct 10 ms 29476 KB Output is correct
20 Correct 8 ms 29272 KB Output is correct
21 Correct 10 ms 29508 KB Output is correct
22 Correct 197 ms 41388 KB Output is correct
23 Correct 181 ms 41808 KB Output is correct
24 Correct 206 ms 43348 KB Output is correct
25 Correct 315 ms 48884 KB Output is correct
26 Correct 180 ms 41556 KB Output is correct
27 Correct 315 ms 48948 KB Output is correct
28 Correct 314 ms 48980 KB Output is correct
29 Correct 169 ms 41556 KB Output is correct
30 Correct 132 ms 38332 KB Output is correct
31 Correct 146 ms 39192 KB Output is correct
32 Correct 268 ms 45968 KB Output is correct
33 Correct 132 ms 38580 KB Output is correct
34 Correct 8 ms 29272 KB Output is correct
35 Correct 7 ms 29276 KB Output is correct
36 Correct 7 ms 29276 KB Output is correct
37 Correct 8 ms 29276 KB Output is correct
38 Correct 8 ms 29276 KB Output is correct
39 Correct 9 ms 29272 KB Output is correct
40 Correct 8 ms 29276 KB Output is correct
41 Correct 132 ms 38436 KB Output is correct
42 Correct 144 ms 39188 KB Output is correct
43 Correct 271 ms 45944 KB Output is correct
44 Correct 130 ms 38524 KB Output is correct
45 Correct 93 ms 36548 KB Output is correct
46 Correct 93 ms 36292 KB Output is correct
47 Correct 78 ms 36500 KB Output is correct
48 Correct 76 ms 36308 KB Output is correct
49 Correct 77 ms 36300 KB Output is correct
50 Correct 79 ms 36456 KB Output is correct
51 Correct 539 ms 67008 KB Output is correct
52 Correct 510 ms 67224 KB Output is correct
53 Correct 441 ms 67772 KB Output is correct
54 Correct 427 ms 67920 KB Output is correct
55 Correct 422 ms 67776 KB Output is correct
56 Correct 88 ms 33712 KB Output is correct
57 Correct 93 ms 33692 KB Output is correct
58 Correct 119 ms 37716 KB Output is correct
59 Correct 117 ms 37744 KB Output is correct
60 Correct 99 ms 39248 KB Output is correct
61 Correct 113 ms 39252 KB Output is correct
62 Correct 86 ms 36948 KB Output is correct
63 Correct 101 ms 38736 KB Output is correct
64 Correct 120 ms 37648 KB Output is correct
65 Correct 120 ms 37712 KB Output is correct
66 Correct 106 ms 37972 KB Output is correct
67 Correct 103 ms 38228 KB Output is correct
68 Correct 110 ms 37460 KB Output is correct
69 Correct 121 ms 37200 KB Output is correct
70 Correct 109 ms 37564 KB Output is correct
71 Correct 93 ms 36256 KB Output is correct
72 Correct 99 ms 36288 KB Output is correct
73 Correct 81 ms 36508 KB Output is correct
74 Correct 78 ms 36456 KB Output is correct
75 Correct 79 ms 36300 KB Output is correct
76 Correct 78 ms 36452 KB Output is correct
77 Correct 828 ms 75224 KB Output is correct
78 Correct 870 ms 75288 KB Output is correct
79 Correct 721 ms 82936 KB Output is correct
80 Correct 716 ms 83096 KB Output is correct
81 Correct 673 ms 80856 KB Output is correct
82 Correct 680 ms 82004 KB Output is correct
83 Correct 758 ms 75432 KB Output is correct
84 Correct 743 ms 75352 KB Output is correct
85 Correct 704 ms 76280 KB Output is correct
86 Correct 660 ms 71940 KB Output is correct
87 Correct 620 ms 71172 KB Output is correct
88 Correct 670 ms 79652 KB Output is correct