답안 #1088724

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088724 2024-09-14T22:01:33 Z vladilius Curtains (NOI23_curtains) C++17
100 / 100
832 ms 89940 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second
const int inf = 5e5 + 1;

struct ST{
    struct node{
        int mn, mn2;
    };
    vector<node> t;
    vector<int> p;
    int n;
    ST(int ns){
        n = ns;
        t.assign(4 * n, {0, inf});
        p.resize(4 * n);
    }
    void merge(int& v){
        int vv = 2 * v;
        if (t[vv].mn < t[vv + 1].mn){
            t[v].mn = t[vv].mn;
            t[v].mn2 = min(t[vv + 1].mn, t[vv].mn2);
        }
        else {
            t[v].mn = t[vv + 1].mn;
            t[v].mn2 = min(t[vv].mn, t[vv + 1].mn2);
        }
    }
    void push(int& v){
        if (!p[v]) return;
        int vv = 2 * v;
        t[vv].mn = max(t[vv].mn, p[v]);
        t[vv + 1].mn = max(t[vv + 1].mn, p[v]);
        p[vv] = max(p[vv], p[v]);
        p[vv + 1] = max(p[vv + 1], p[v]);
        p[v] = 0;
    }
    void chmax(int v, int tl, int tr, int& l, int& r, int& x){
        if (l > tr || r < tl || t[v].mn >= x) return;
        if (l <= tl && tr <= r && t[v].mn2 > x){
            t[v].mn = x;
            p[v] = x;
            return;
        }
        int tm = (tl + tr) / 2, vv = 2 * v;
        push(v);
        chmax(vv, tl, tm, l, r, x);
        chmax(vv + 1, tm + 1, tr, l, r, x);
        merge(v);
    }
    void chmax(int l, int r, int x){
        chmax(1, 1, n, l, r, x);
    }
    int get(int v, int tl, int tr, int& l, int& r){
        if (l > tr || r < tl) return inf;
        if (l <= tl && tr <= r) return t[v].mn;
        push(v);
        int tm = (tl + tr) / 2, vv = 2 * v;
        return min(get(vv, tl, tm, l, r), get(vv + 1, tm + 1, tr, l, r));
    }
    int get(int l, int r){
        return get(1, 1, n, l, r);
    }
};

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    int n, m, q; cin>>n>>m>>q;
    vector<int> st[n + 1];
    while (m--){
        int l, r; cin>>l>>r;
        st[r].pb(l);
    }
    vector<pii> qs[n + 1];
    for (int i = 1; i <= q; i++){
        int l, r; cin>>l>>r;
        qs[r].pb({l, i});
    }
    vector<int> out(q + 1);
    ST T(n);
    for (int r = 1; r <= n; r++){
        for (int l: st[r]){
            T.chmax(l, r, l);
        }
        for (auto [l, i]: qs[r]){
            out[i] = (T.get(l, r) >= l);
        }
    }
    
    for (int i = 1; i <= q; i++){
        cout<<(out[i] ? "YES" : "NO")<<"\n";
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 560 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 560 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 720 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 668 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 560 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 720 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 668 KB Output is correct
22 Correct 125 ms 14504 KB Output is correct
23 Correct 132 ms 15044 KB Output is correct
24 Correct 157 ms 16464 KB Output is correct
25 Correct 273 ms 22376 KB Output is correct
26 Correct 129 ms 14896 KB Output is correct
27 Correct 275 ms 22356 KB Output is correct
28 Correct 274 ms 22292 KB Output is correct
29 Correct 128 ms 13852 KB Output is correct
30 Correct 121 ms 13908 KB Output is correct
31 Correct 104 ms 14708 KB Output is correct
32 Correct 255 ms 21252 KB Output is correct
33 Correct 126 ms 14164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 452 KB Output is correct
5 Correct 2 ms 604 KB Output is correct
6 Correct 2 ms 604 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 90 ms 13920 KB Output is correct
9 Correct 101 ms 14692 KB Output is correct
10 Correct 241 ms 21376 KB Output is correct
11 Correct 96 ms 13964 KB Output is correct
12 Correct 107 ms 17340 KB Output is correct
13 Correct 110 ms 17224 KB Output is correct
14 Correct 108 ms 17492 KB Output is correct
15 Correct 84 ms 16976 KB Output is correct
16 Correct 77 ms 17492 KB Output is correct
17 Correct 85 ms 17156 KB Output is correct
18 Correct 708 ms 86428 KB Output is correct
19 Correct 750 ms 86612 KB Output is correct
20 Correct 543 ms 87216 KB Output is correct
21 Correct 518 ms 86440 KB Output is correct
22 Correct 545 ms 85584 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 560 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 720 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 668 KB Output is correct
22 Correct 77 ms 6200 KB Output is correct
23 Correct 75 ms 6160 KB Output is correct
24 Correct 129 ms 16568 KB Output is correct
25 Correct 147 ms 16468 KB Output is correct
26 Correct 88 ms 17804 KB Output is correct
27 Correct 97 ms 17856 KB Output is correct
28 Correct 73 ms 15572 KB Output is correct
29 Correct 78 ms 17236 KB Output is correct
30 Correct 124 ms 16468 KB Output is correct
31 Correct 113 ms 16464 KB Output is correct
32 Correct 96 ms 17004 KB Output is correct
33 Correct 95 ms 17236 KB Output is correct
34 Correct 141 ms 15980 KB Output is correct
35 Correct 151 ms 16468 KB Output is correct
36 Correct 100 ms 16980 KB Output is correct
37 Correct 106 ms 17236 KB Output is correct
38 Correct 105 ms 17348 KB Output is correct
39 Correct 109 ms 17428 KB Output is correct
40 Correct 69 ms 17100 KB Output is correct
41 Correct 73 ms 17444 KB Output is correct
42 Correct 93 ms 17012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 ms 560 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 448 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 720 KB Output is correct
15 Correct 2 ms 760 KB Output is correct
16 Correct 2 ms 760 KB Output is correct
17 Correct 2 ms 600 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 3 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 668 KB Output is correct
22 Correct 125 ms 14504 KB Output is correct
23 Correct 132 ms 15044 KB Output is correct
24 Correct 157 ms 16464 KB Output is correct
25 Correct 273 ms 22376 KB Output is correct
26 Correct 129 ms 14896 KB Output is correct
27 Correct 275 ms 22356 KB Output is correct
28 Correct 274 ms 22292 KB Output is correct
29 Correct 128 ms 13852 KB Output is correct
30 Correct 121 ms 13908 KB Output is correct
31 Correct 104 ms 14708 KB Output is correct
32 Correct 255 ms 21252 KB Output is correct
33 Correct 126 ms 14164 KB Output is correct
34 Correct 0 ms 344 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 452 KB Output is correct
38 Correct 2 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 90 ms 13920 KB Output is correct
42 Correct 101 ms 14692 KB Output is correct
43 Correct 241 ms 21376 KB Output is correct
44 Correct 96 ms 13964 KB Output is correct
45 Correct 107 ms 17340 KB Output is correct
46 Correct 110 ms 17224 KB Output is correct
47 Correct 108 ms 17492 KB Output is correct
48 Correct 84 ms 16976 KB Output is correct
49 Correct 77 ms 17492 KB Output is correct
50 Correct 85 ms 17156 KB Output is correct
51 Correct 708 ms 86428 KB Output is correct
52 Correct 750 ms 86612 KB Output is correct
53 Correct 543 ms 87216 KB Output is correct
54 Correct 518 ms 86440 KB Output is correct
55 Correct 545 ms 85584 KB Output is correct
56 Correct 77 ms 6200 KB Output is correct
57 Correct 75 ms 6160 KB Output is correct
58 Correct 129 ms 16568 KB Output is correct
59 Correct 147 ms 16468 KB Output is correct
60 Correct 88 ms 17804 KB Output is correct
61 Correct 97 ms 17856 KB Output is correct
62 Correct 73 ms 15572 KB Output is correct
63 Correct 78 ms 17236 KB Output is correct
64 Correct 124 ms 16468 KB Output is correct
65 Correct 113 ms 16464 KB Output is correct
66 Correct 96 ms 17004 KB Output is correct
67 Correct 95 ms 17236 KB Output is correct
68 Correct 141 ms 15980 KB Output is correct
69 Correct 151 ms 16468 KB Output is correct
70 Correct 100 ms 16980 KB Output is correct
71 Correct 106 ms 17236 KB Output is correct
72 Correct 105 ms 17348 KB Output is correct
73 Correct 109 ms 17428 KB Output is correct
74 Correct 69 ms 17100 KB Output is correct
75 Correct 73 ms 17444 KB Output is correct
76 Correct 93 ms 17012 KB Output is correct
77 Correct 832 ms 83100 KB Output is correct
78 Correct 819 ms 83068 KB Output is correct
79 Correct 527 ms 89684 KB Output is correct
80 Correct 573 ms 89940 KB Output is correct
81 Correct 569 ms 87572 KB Output is correct
82 Correct 520 ms 88592 KB Output is correct
83 Correct 733 ms 82976 KB Output is correct
84 Correct 749 ms 82920 KB Output is correct
85 Correct 655 ms 84560 KB Output is correct
86 Correct 689 ms 81264 KB Output is correct
87 Correct 661 ms 80980 KB Output is correct
88 Correct 555 ms 87636 KB Output is correct