Submission #1006107

# Submission time Handle Problem Language Result Execution time Memory
1006107 2024-06-23T12:06:46 Z vjudge1 Curtains (NOI23_curtains) C++17
100 / 100
814 ms 74344 KB
#include <bits/stdc++.h>

using namespace std;
using ll = long long;

#define int long long
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (b); i >= (a); i --)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPD(i, n) for (int i =(n) - 1; i >= 0; --i)

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1)


constexpr ll LINF = (1ll << 60);
constexpr int INF = (1ll << 30);
constexpr int Mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

/*
    Phu Trong from Nguyen Tat Thanh High School for gifted student
*/

template <class X, class Y>
    bool minimize(X &x, const Y &y){
        X eps = 1e-9;
        if (x > y + eps) {x = y; return 1;}
        return 0;
    }

template <class X, class Y>
    bool maximize(X &x, const Y &y){
        X eps = 1e-9;
        if (x + eps < y) {x = y; return 1;}
        return 0;
    }

#define MAX         500005
int nArr, nCurtain, numQuery;

vector<int> event[MAX];
vector<pair<int, int>> Q[MAX];

int lz[MAX * 4], st[MAX * 4];

void pushDown(int id){
    if (!lz[id]) return;
    maximize(st[id << 1], lz[id]);
    maximize(st[id << 1 | 1], lz[id]);
    maximize(lz[id << 1], lz[id]);
    maximize(lz[id << 1 | 1], lz[id]);
    lz[id] = 0;
}
void upd(int id, int l, int r, int u, int v, int val){
    if (u > r || v < l) return;
    if (u <= l && v >= r){
        maximize(st[id], val);
        maximize(lz[id], val);
        return;
    }
    int m = (l + r) >> 1;
    pushDown(id);
    upd(id << 1, l, m, u, v, val);
    upd(id << 1 | 1, m + 1, r, u, v, val);
    st[id] = min(st[id << 1], st[id << 1 | 1]);
}
int query(int id, int l, int r, int u, int v){
    if (u > r || v < l) return 1e9;
    if (u <= l && v >= r) return st[id];
    int m = (l + r) >> 1;
    pushDown(id);
    int ql = query(id << 1, l, m, u, v);
    int qr = query(id << 1 | 1, m + 1, r, u, v);
    return min(ql, qr);
}

int ans[MAX];
void process(void){
    cin >> nArr >> nCurtain >> numQuery;
    for (int i = 1; i <= nCurtain; ++i){
        int l, r; cin >> l >> r;
        event[r].emplace_back(l);
    }
    for (int i = 1; i <= numQuery; ++i){
        int l, r; cin >> l >> r;
        Q[r].emplace_back(l, i);
    }

    for (int r = 1; r <= nArr; ++r){
        for (int &l : event[r]){
            upd(1, 1, nArr, l, r, l);
        }
        for (auto&[l, i] : Q[r]){
            ans[i] = (query(1, 1, nArr, l, r) >= l);
        }
    }
    for (int i = 1; i <= numQuery; ++i){
        cout << (ans[i] ? "YES" : "NO") << "\n";
    }
}

signed main(){
    #define name "Whisper"
    cin.tie(nullptr) -> sync_with_stdio(false);
    //freopen(name".inp", "r", stdin);
    //freopen(name".out", "w", stdout);
    process();
}
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23900 KB Output is correct
2 Correct 4 ms 23896 KB Output is correct
3 Correct 5 ms 23896 KB Output is correct
4 Correct 4 ms 23896 KB Output is correct
5 Correct 4 ms 23900 KB Output is correct
6 Correct 5 ms 23900 KB Output is correct
7 Correct 4 ms 23900 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 24148 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
11 Correct 5 ms 23996 KB Output is correct
12 Correct 4 ms 23900 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23900 KB Output is correct
2 Correct 4 ms 23896 KB Output is correct
3 Correct 5 ms 23896 KB Output is correct
4 Correct 4 ms 23896 KB Output is correct
5 Correct 4 ms 23900 KB Output is correct
6 Correct 5 ms 23900 KB Output is correct
7 Correct 4 ms 23900 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 24148 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
11 Correct 5 ms 23996 KB Output is correct
12 Correct 4 ms 23900 KB Output is correct
13 Correct 6 ms 24156 KB Output is correct
14 Correct 7 ms 24308 KB Output is correct
15 Correct 5 ms 24156 KB Output is correct
16 Correct 6 ms 24156 KB Output is correct
17 Correct 5 ms 24156 KB Output is correct
18 Correct 5 ms 24408 KB Output is correct
19 Correct 5 ms 24152 KB Output is correct
20 Correct 5 ms 24156 KB Output is correct
21 Correct 5 ms 24156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23900 KB Output is correct
2 Correct 4 ms 23896 KB Output is correct
3 Correct 5 ms 23896 KB Output is correct
4 Correct 4 ms 23896 KB Output is correct
5 Correct 4 ms 23900 KB Output is correct
6 Correct 5 ms 23900 KB Output is correct
7 Correct 4 ms 23900 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 24148 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
11 Correct 5 ms 23996 KB Output is correct
12 Correct 4 ms 23900 KB Output is correct
13 Correct 6 ms 24156 KB Output is correct
14 Correct 7 ms 24308 KB Output is correct
15 Correct 5 ms 24156 KB Output is correct
16 Correct 6 ms 24156 KB Output is correct
17 Correct 5 ms 24156 KB Output is correct
18 Correct 5 ms 24408 KB Output is correct
19 Correct 5 ms 24152 KB Output is correct
20 Correct 5 ms 24156 KB Output is correct
21 Correct 5 ms 24156 KB Output is correct
22 Correct 149 ms 41552 KB Output is correct
23 Correct 170 ms 42064 KB Output is correct
24 Correct 192 ms 43048 KB Output is correct
25 Correct 321 ms 47440 KB Output is correct
26 Correct 154 ms 41808 KB Output is correct
27 Correct 361 ms 47696 KB Output is correct
28 Correct 316 ms 47696 KB Output is correct
29 Correct 135 ms 40276 KB Output is correct
30 Correct 102 ms 42552 KB Output is correct
31 Correct 125 ms 43204 KB Output is correct
32 Correct 266 ms 48444 KB Output is correct
33 Correct 105 ms 42832 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 23896 KB Output is correct
2 Correct 4 ms 23900 KB Output is correct
3 Correct 4 ms 23900 KB Output is correct
4 Correct 4 ms 23900 KB Output is correct
5 Correct 5 ms 24156 KB Output is correct
6 Correct 5 ms 24156 KB Output is correct
7 Correct 5 ms 24180 KB Output is correct
8 Correct 103 ms 42424 KB Output is correct
9 Correct 133 ms 43172 KB Output is correct
10 Correct 252 ms 48464 KB Output is correct
11 Correct 94 ms 42580 KB Output is correct
12 Correct 97 ms 35752 KB Output is correct
13 Correct 101 ms 35644 KB Output is correct
14 Correct 81 ms 37460 KB Output is correct
15 Correct 73 ms 35412 KB Output is correct
16 Correct 71 ms 35740 KB Output is correct
17 Correct 77 ms 37040 KB Output is correct
18 Correct 624 ms 71508 KB Output is correct
19 Correct 627 ms 71544 KB Output is correct
20 Correct 448 ms 71504 KB Output is correct
21 Correct 434 ms 70996 KB Output is correct
22 Correct 389 ms 70224 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23900 KB Output is correct
2 Correct 4 ms 23896 KB Output is correct
3 Correct 5 ms 23896 KB Output is correct
4 Correct 4 ms 23896 KB Output is correct
5 Correct 4 ms 23900 KB Output is correct
6 Correct 5 ms 23900 KB Output is correct
7 Correct 4 ms 23900 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 24148 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
11 Correct 5 ms 23996 KB Output is correct
12 Correct 4 ms 23900 KB Output is correct
13 Correct 6 ms 24156 KB Output is correct
14 Correct 7 ms 24308 KB Output is correct
15 Correct 5 ms 24156 KB Output is correct
16 Correct 6 ms 24156 KB Output is correct
17 Correct 5 ms 24156 KB Output is correct
18 Correct 5 ms 24408 KB Output is correct
19 Correct 5 ms 24152 KB Output is correct
20 Correct 5 ms 24156 KB Output is correct
21 Correct 5 ms 24156 KB Output is correct
22 Correct 93 ms 31148 KB Output is correct
23 Correct 88 ms 31096 KB Output is correct
24 Correct 126 ms 36948 KB Output is correct
25 Correct 125 ms 35156 KB Output is correct
26 Correct 93 ms 37456 KB Output is correct
27 Correct 107 ms 36176 KB Output is correct
28 Correct 71 ms 36436 KB Output is correct
29 Correct 88 ms 37200 KB Output is correct
30 Correct 125 ms 35328 KB Output is correct
31 Correct 136 ms 35152 KB Output is correct
32 Correct 108 ms 37252 KB Output is correct
33 Correct 99 ms 37356 KB Output is correct
34 Correct 106 ms 36852 KB Output is correct
35 Correct 108 ms 36948 KB Output is correct
36 Correct 100 ms 37456 KB Output is correct
37 Correct 101 ms 35664 KB Output is correct
38 Correct 112 ms 35856 KB Output is correct
39 Correct 70 ms 37460 KB Output is correct
40 Correct 77 ms 35404 KB Output is correct
41 Correct 73 ms 35664 KB Output is correct
42 Correct 72 ms 37204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 23900 KB Output is correct
2 Correct 4 ms 23896 KB Output is correct
3 Correct 5 ms 23896 KB Output is correct
4 Correct 4 ms 23896 KB Output is correct
5 Correct 4 ms 23900 KB Output is correct
6 Correct 5 ms 23900 KB Output is correct
7 Correct 4 ms 23900 KB Output is correct
8 Correct 4 ms 23900 KB Output is correct
9 Correct 4 ms 24148 KB Output is correct
10 Correct 4 ms 23900 KB Output is correct
11 Correct 5 ms 23996 KB Output is correct
12 Correct 4 ms 23900 KB Output is correct
13 Correct 6 ms 24156 KB Output is correct
14 Correct 7 ms 24308 KB Output is correct
15 Correct 5 ms 24156 KB Output is correct
16 Correct 6 ms 24156 KB Output is correct
17 Correct 5 ms 24156 KB Output is correct
18 Correct 5 ms 24408 KB Output is correct
19 Correct 5 ms 24152 KB Output is correct
20 Correct 5 ms 24156 KB Output is correct
21 Correct 5 ms 24156 KB Output is correct
22 Correct 149 ms 41552 KB Output is correct
23 Correct 170 ms 42064 KB Output is correct
24 Correct 192 ms 43048 KB Output is correct
25 Correct 321 ms 47440 KB Output is correct
26 Correct 154 ms 41808 KB Output is correct
27 Correct 361 ms 47696 KB Output is correct
28 Correct 316 ms 47696 KB Output is correct
29 Correct 135 ms 40276 KB Output is correct
30 Correct 102 ms 42552 KB Output is correct
31 Correct 125 ms 43204 KB Output is correct
32 Correct 266 ms 48444 KB Output is correct
33 Correct 105 ms 42832 KB Output is correct
34 Correct 6 ms 23896 KB Output is correct
35 Correct 4 ms 23900 KB Output is correct
36 Correct 4 ms 23900 KB Output is correct
37 Correct 4 ms 23900 KB Output is correct
38 Correct 5 ms 24156 KB Output is correct
39 Correct 5 ms 24156 KB Output is correct
40 Correct 5 ms 24180 KB Output is correct
41 Correct 103 ms 42424 KB Output is correct
42 Correct 133 ms 43172 KB Output is correct
43 Correct 252 ms 48464 KB Output is correct
44 Correct 94 ms 42580 KB Output is correct
45 Correct 97 ms 35752 KB Output is correct
46 Correct 101 ms 35644 KB Output is correct
47 Correct 81 ms 37460 KB Output is correct
48 Correct 73 ms 35412 KB Output is correct
49 Correct 71 ms 35740 KB Output is correct
50 Correct 77 ms 37040 KB Output is correct
51 Correct 624 ms 71508 KB Output is correct
52 Correct 627 ms 71544 KB Output is correct
53 Correct 448 ms 71504 KB Output is correct
54 Correct 434 ms 70996 KB Output is correct
55 Correct 389 ms 70224 KB Output is correct
56 Correct 93 ms 31148 KB Output is correct
57 Correct 88 ms 31096 KB Output is correct
58 Correct 126 ms 36948 KB Output is correct
59 Correct 125 ms 35156 KB Output is correct
60 Correct 93 ms 37456 KB Output is correct
61 Correct 107 ms 36176 KB Output is correct
62 Correct 71 ms 36436 KB Output is correct
63 Correct 88 ms 37200 KB Output is correct
64 Correct 125 ms 35328 KB Output is correct
65 Correct 136 ms 35152 KB Output is correct
66 Correct 108 ms 37252 KB Output is correct
67 Correct 99 ms 37356 KB Output is correct
68 Correct 106 ms 36852 KB Output is correct
69 Correct 108 ms 36948 KB Output is correct
70 Correct 100 ms 37456 KB Output is correct
71 Correct 101 ms 35664 KB Output is correct
72 Correct 112 ms 35856 KB Output is correct
73 Correct 70 ms 37460 KB Output is correct
74 Correct 77 ms 35404 KB Output is correct
75 Correct 73 ms 35664 KB Output is correct
76 Correct 72 ms 37204 KB Output is correct
77 Correct 814 ms 68972 KB Output is correct
78 Correct 800 ms 68888 KB Output is correct
79 Correct 564 ms 72856 KB Output is correct
80 Correct 550 ms 74344 KB Output is correct
81 Correct 508 ms 72784 KB Output is correct
82 Correct 480 ms 71844 KB Output is correct
83 Correct 813 ms 68888 KB Output is correct
84 Correct 791 ms 68912 KB Output is correct
85 Correct 686 ms 69892 KB Output is correct
86 Correct 664 ms 68360 KB Output is correct
87 Correct 613 ms 68436 KB Output is correct
88 Correct 565 ms 73300 KB Output is correct