Submission #887039

# Submission time Handle Problem Language Result Execution time Memory
887039 2023-12-13T14:10:16 Z underwaterkillerwhale Curtains (NOI23_curtains) C++14
100 / 100
767 ms 83236 KB
#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define rep(i,m,n) for(int i=(m); i<=(n); i++)
#define reb(i,m,n) for(int i=(m); i>=(n); i--)
#define iter(id, v) for (auto id : v)
#define ii pair<ll,ll>
#define fs first
#define se second
#define pb push_back
#define SZ(v) (int)v.size()
#define ALL(v) v.begin(), v.end()
#define bit(msk, i) ((msk >> i) & 1)

template<typename A, typename B> ostream& operator<<(ostream& out, const pair<A, B> &v) {
    out << "(" << v.fs << "," << v.se << ") ";
    return out;
}

//#ifndef ONLINE_JUDGE
//#include "debug.h"
//#else
//#define deb(...) 23
//#define ____
//#endif

mt19937_64 rd(chrono :: steady_clock :: now().time_since_epoch().count());
ll Rand(ll l, ll r) {
    return uniform_int_distribution<ll> (l, r)(rd);
}

const ll N = 5e5 + 7;
const ll Mod = 1e9 + 7;
const ll szBL = 650;
const ll INF = 2e9;
const ll B = 137;

ll n, m, Q;
vector<int> events[N];
vector<pair<int,int>> query[N];

struct Segment_Tree {
    ll Range;
    ll st[N << 2], lz[N << 2];

    void init(ll n) {
        Range = n;
    }

    void down (ll id) {
        rep (i, id << 1, id << 1 | 1) {
            lz[i] = max(lz[id], lz[i]);
            st[i] = max(lz[id], st[i]);
        }
        lz[id] = 0;
    }

    void update (ll id, ll l, ll r, ll u, ll v, ll val) {
        if (l > v or r < u)
            return;
        if (l >= u && r <= v) {
            st[id] = max(st[id], val);
            lz[id] = max(lz[id], val);
            return;
        }
        down(id);
        ll mid = l + r >> 1;
        update (id << 1, l, mid, u, v, val);
        update (id << 1 | 1, mid + 1, r, u, v, val);
        st[id] = min(st[id << 1], st[id << 1 | 1]);
    }

    ll get (ll id, ll l, ll r, ll u, ll v) {
        if (l > v or r < u) return INF;
        if (l >= u && r <= v) return st[id];
        down(id);
        ll mid = l + r >> 1;
        return min(get (id << 1, l, mid, u, v), get (id << 1 | 1, mid + 1, r, u, v));
    }

    void update (ll u, ll v, ll val) {
        update (1, 1, Range, u, v, val);
    }
    ll get (ll u, ll v) {
        return get (1, 1, Range, u, v);
    }
}ST;

void chloe_solution() {
    cin >> n >> m >> Q;
    ST.init(n);
    rep (i, 1, m) {
        ll L, R;
        cin >> L >> R;
        events[R].pb(L);
    }
    rep (i, 1, Q) {
        ll S, E;
        cin >> S >> E;
        query[E].pb({S, i});
    }
    vector<int> Ans(Q + 2);
    rep (i, 1, n) {
        ll R = i;
        iter (&L, events[R]) {
            ST.update(L, R, L);
        }
        iter (&id, query[R]) {
            ll L = id.fs;
            ll idx = id.se;
            if (ST.get(L, R) == L) {
                Ans[idx] = 1;
            }
        }
    }
    rep (i, 1, Q) if (Ans[i]) cout <<"YES\n"; else cout <<"NO\n";
}

#define file(name) freopen(name".inp", "r", stdin); freopen(name".out", "w", stdout);

int main() {
//    file("c");
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll num_Test = 1;
//    cin >> num_Test;
    while(num_Test--)
        chloe_solution();
}
/*
7 1
1 3 4 5 4 4 1
2 3 6


*/

Compilation message

curtains.cpp: In member function 'void Segment_Tree::update(long long int, long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:69:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   69 |         ll mid = l + r >> 1;
      |                  ~~^~~
curtains.cpp: In member function 'long long int Segment_Tree::get(long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:79:20: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   79 |         ll mid = l + r >> 1;
      |                  ~~^~~
# Verdict Execution time Memory Grader output
1 Correct 6 ms 24156 KB Output is correct
2 Correct 5 ms 24156 KB Output is correct
3 Correct 5 ms 24152 KB Output is correct
4 Correct 5 ms 24156 KB Output is correct
5 Correct 7 ms 24264 KB Output is correct
6 Correct 6 ms 24156 KB Output is correct
7 Correct 5 ms 24156 KB Output is correct
8 Correct 5 ms 24268 KB Output is correct
9 Correct 5 ms 24156 KB Output is correct
10 Correct 6 ms 24156 KB Output is correct
11 Correct 6 ms 24156 KB Output is correct
12 Correct 6 ms 24120 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 24156 KB Output is correct
2 Correct 5 ms 24156 KB Output is correct
3 Correct 5 ms 24152 KB Output is correct
4 Correct 5 ms 24156 KB Output is correct
5 Correct 7 ms 24264 KB Output is correct
6 Correct 6 ms 24156 KB Output is correct
7 Correct 5 ms 24156 KB Output is correct
8 Correct 5 ms 24268 KB Output is correct
9 Correct 5 ms 24156 KB Output is correct
10 Correct 6 ms 24156 KB Output is correct
11 Correct 6 ms 24156 KB Output is correct
12 Correct 6 ms 24120 KB Output is correct
13 Correct 7 ms 24408 KB Output is correct
14 Correct 7 ms 24472 KB Output is correct
15 Correct 7 ms 24412 KB Output is correct
16 Correct 7 ms 24412 KB Output is correct
17 Correct 8 ms 24412 KB Output is correct
18 Correct 7 ms 24412 KB Output is correct
19 Correct 6 ms 24460 KB Output is correct
20 Correct 7 ms 24412 KB Output is correct
21 Correct 7 ms 24412 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 24156 KB Output is correct
2 Correct 5 ms 24156 KB Output is correct
3 Correct 5 ms 24152 KB Output is correct
4 Correct 5 ms 24156 KB Output is correct
5 Correct 7 ms 24264 KB Output is correct
6 Correct 6 ms 24156 KB Output is correct
7 Correct 5 ms 24156 KB Output is correct
8 Correct 5 ms 24268 KB Output is correct
9 Correct 5 ms 24156 KB Output is correct
10 Correct 6 ms 24156 KB Output is correct
11 Correct 6 ms 24156 KB Output is correct
12 Correct 6 ms 24120 KB Output is correct
13 Correct 7 ms 24408 KB Output is correct
14 Correct 7 ms 24472 KB Output is correct
15 Correct 7 ms 24412 KB Output is correct
16 Correct 7 ms 24412 KB Output is correct
17 Correct 8 ms 24412 KB Output is correct
18 Correct 7 ms 24412 KB Output is correct
19 Correct 6 ms 24460 KB Output is correct
20 Correct 7 ms 24412 KB Output is correct
21 Correct 7 ms 24412 KB Output is correct
22 Correct 141 ms 34100 KB Output is correct
23 Correct 144 ms 34476 KB Output is correct
24 Correct 169 ms 34916 KB Output is correct
25 Correct 289 ms 37720 KB Output is correct
26 Correct 143 ms 34128 KB Output is correct
27 Correct 275 ms 37200 KB Output is correct
28 Correct 274 ms 37384 KB Output is correct
29 Correct 132 ms 33276 KB Output is correct
30 Correct 102 ms 34936 KB Output is correct
31 Correct 103 ms 35120 KB Output is correct
32 Correct 226 ms 37712 KB Output is correct
33 Correct 96 ms 34692 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 24156 KB Output is correct
2 Correct 6 ms 24156 KB Output is correct
3 Correct 6 ms 24276 KB Output is correct
4 Correct 6 ms 24268 KB Output is correct
5 Correct 7 ms 24408 KB Output is correct
6 Correct 6 ms 24412 KB Output is correct
7 Correct 7 ms 24252 KB Output is correct
8 Correct 96 ms 34636 KB Output is correct
9 Correct 105 ms 34900 KB Output is correct
10 Correct 224 ms 37712 KB Output is correct
11 Correct 93 ms 34640 KB Output is correct
12 Correct 90 ms 35892 KB Output is correct
13 Correct 95 ms 35852 KB Output is correct
14 Correct 73 ms 36128 KB Output is correct
15 Correct 80 ms 35492 KB Output is correct
16 Correct 73 ms 35924 KB Output is correct
17 Correct 74 ms 35556 KB Output is correct
18 Correct 614 ms 79952 KB Output is correct
19 Correct 609 ms 79840 KB Output is correct
20 Correct 469 ms 80796 KB Output is correct
21 Correct 489 ms 79756 KB Output is correct
22 Correct 456 ms 78988 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 24156 KB Output is correct
2 Correct 5 ms 24156 KB Output is correct
3 Correct 5 ms 24152 KB Output is correct
4 Correct 5 ms 24156 KB Output is correct
5 Correct 7 ms 24264 KB Output is correct
6 Correct 6 ms 24156 KB Output is correct
7 Correct 5 ms 24156 KB Output is correct
8 Correct 5 ms 24268 KB Output is correct
9 Correct 5 ms 24156 KB Output is correct
10 Correct 6 ms 24156 KB Output is correct
11 Correct 6 ms 24156 KB Output is correct
12 Correct 6 ms 24120 KB Output is correct
13 Correct 7 ms 24408 KB Output is correct
14 Correct 7 ms 24472 KB Output is correct
15 Correct 7 ms 24412 KB Output is correct
16 Correct 7 ms 24412 KB Output is correct
17 Correct 8 ms 24412 KB Output is correct
18 Correct 7 ms 24412 KB Output is correct
19 Correct 6 ms 24460 KB Output is correct
20 Correct 7 ms 24412 KB Output is correct
21 Correct 7 ms 24412 KB Output is correct
22 Correct 80 ms 29524 KB Output is correct
23 Correct 79 ms 29684 KB Output is correct
24 Correct 109 ms 35152 KB Output is correct
25 Correct 114 ms 35204 KB Output is correct
26 Correct 91 ms 36392 KB Output is correct
27 Correct 92 ms 36436 KB Output is correct
28 Correct 74 ms 34132 KB Output is correct
29 Correct 86 ms 35988 KB Output is correct
30 Correct 108 ms 35152 KB Output is correct
31 Correct 119 ms 35100 KB Output is correct
32 Correct 99 ms 35496 KB Output is correct
33 Correct 93 ms 35928 KB Output is correct
34 Correct 102 ms 34620 KB Output is correct
35 Correct 103 ms 35044 KB Output is correct
36 Correct 100 ms 35580 KB Output is correct
37 Correct 96 ms 36012 KB Output is correct
38 Correct 90 ms 35940 KB Output is correct
39 Correct 72 ms 35920 KB Output is correct
40 Correct 73 ms 35668 KB Output is correct
41 Correct 75 ms 36044 KB Output is correct
42 Correct 73 ms 35664 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 24156 KB Output is correct
2 Correct 5 ms 24156 KB Output is correct
3 Correct 5 ms 24152 KB Output is correct
4 Correct 5 ms 24156 KB Output is correct
5 Correct 7 ms 24264 KB Output is correct
6 Correct 6 ms 24156 KB Output is correct
7 Correct 5 ms 24156 KB Output is correct
8 Correct 5 ms 24268 KB Output is correct
9 Correct 5 ms 24156 KB Output is correct
10 Correct 6 ms 24156 KB Output is correct
11 Correct 6 ms 24156 KB Output is correct
12 Correct 6 ms 24120 KB Output is correct
13 Correct 7 ms 24408 KB Output is correct
14 Correct 7 ms 24472 KB Output is correct
15 Correct 7 ms 24412 KB Output is correct
16 Correct 7 ms 24412 KB Output is correct
17 Correct 8 ms 24412 KB Output is correct
18 Correct 7 ms 24412 KB Output is correct
19 Correct 6 ms 24460 KB Output is correct
20 Correct 7 ms 24412 KB Output is correct
21 Correct 7 ms 24412 KB Output is correct
22 Correct 141 ms 34100 KB Output is correct
23 Correct 144 ms 34476 KB Output is correct
24 Correct 169 ms 34916 KB Output is correct
25 Correct 289 ms 37720 KB Output is correct
26 Correct 143 ms 34128 KB Output is correct
27 Correct 275 ms 37200 KB Output is correct
28 Correct 274 ms 37384 KB Output is correct
29 Correct 132 ms 33276 KB Output is correct
30 Correct 102 ms 34936 KB Output is correct
31 Correct 103 ms 35120 KB Output is correct
32 Correct 226 ms 37712 KB Output is correct
33 Correct 96 ms 34692 KB Output is correct
34 Correct 5 ms 24156 KB Output is correct
35 Correct 6 ms 24156 KB Output is correct
36 Correct 6 ms 24276 KB Output is correct
37 Correct 6 ms 24268 KB Output is correct
38 Correct 7 ms 24408 KB Output is correct
39 Correct 6 ms 24412 KB Output is correct
40 Correct 7 ms 24252 KB Output is correct
41 Correct 96 ms 34636 KB Output is correct
42 Correct 105 ms 34900 KB Output is correct
43 Correct 224 ms 37712 KB Output is correct
44 Correct 93 ms 34640 KB Output is correct
45 Correct 90 ms 35892 KB Output is correct
46 Correct 95 ms 35852 KB Output is correct
47 Correct 73 ms 36128 KB Output is correct
48 Correct 80 ms 35492 KB Output is correct
49 Correct 73 ms 35924 KB Output is correct
50 Correct 74 ms 35556 KB Output is correct
51 Correct 614 ms 79952 KB Output is correct
52 Correct 609 ms 79840 KB Output is correct
53 Correct 469 ms 80796 KB Output is correct
54 Correct 489 ms 79756 KB Output is correct
55 Correct 456 ms 78988 KB Output is correct
56 Correct 80 ms 29524 KB Output is correct
57 Correct 79 ms 29684 KB Output is correct
58 Correct 109 ms 35152 KB Output is correct
59 Correct 114 ms 35204 KB Output is correct
60 Correct 91 ms 36392 KB Output is correct
61 Correct 92 ms 36436 KB Output is correct
62 Correct 74 ms 34132 KB Output is correct
63 Correct 86 ms 35988 KB Output is correct
64 Correct 108 ms 35152 KB Output is correct
65 Correct 119 ms 35100 KB Output is correct
66 Correct 99 ms 35496 KB Output is correct
67 Correct 93 ms 35928 KB Output is correct
68 Correct 102 ms 34620 KB Output is correct
69 Correct 103 ms 35044 KB Output is correct
70 Correct 100 ms 35580 KB Output is correct
71 Correct 96 ms 36012 KB Output is correct
72 Correct 90 ms 35940 KB Output is correct
73 Correct 72 ms 35920 KB Output is correct
74 Correct 73 ms 35668 KB Output is correct
75 Correct 75 ms 36044 KB Output is correct
76 Correct 73 ms 35664 KB Output is correct
77 Correct 734 ms 76268 KB Output is correct
78 Correct 731 ms 76368 KB Output is correct
79 Correct 623 ms 83024 KB Output is correct
80 Correct 655 ms 83236 KB Output is correct
81 Correct 634 ms 80940 KB Output is correct
82 Correct 614 ms 82456 KB Output is correct
83 Correct 738 ms 76760 KB Output is correct
84 Correct 767 ms 76004 KB Output is correct
85 Correct 710 ms 78028 KB Output is correct
86 Correct 648 ms 74560 KB Output is correct
87 Correct 639 ms 74320 KB Output is correct
88 Correct 674 ms 81152 KB Output is correct