답안 #887038

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
887038 2023-12-13T14:09:40 Z underwaterkillerwhale Curtains (NOI23_curtains) C++14
24 / 100
281 ms 22360 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 = 3e3 + 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;
      |                  ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 608 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 608 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 784 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 608 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 784 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 137 ms 14696 KB Output is correct
23 Correct 141 ms 15188 KB Output is correct
24 Correct 178 ms 16428 KB Output is correct
25 Correct 274 ms 22360 KB Output is correct
26 Correct 141 ms 14756 KB Output is correct
27 Correct 281 ms 22216 KB Output is correct
28 Correct 276 ms 22356 KB Output is correct
29 Correct 133 ms 13908 KB Output is correct
30 Correct 87 ms 13912 KB Output is correct
31 Correct 101 ms 14624 KB Output is correct
32 Correct 227 ms 21680 KB Output is correct
33 Correct 87 ms 14164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 604 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 0 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 2 ms 600 KB Output is correct
6 Correct 2 ms 672 KB Output is correct
7 Correct 2 ms 604 KB Output is correct
8 Correct 87 ms 13908 KB Output is correct
9 Correct 99 ms 14644 KB Output is correct
10 Correct 220 ms 21292 KB Output is correct
11 Correct 86 ms 13968 KB Output is correct
12 Runtime error 1 ms 860 KB Execution killed with signal 11
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 608 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 784 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Runtime error 1 ms 860 KB Execution killed with signal 11
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 0 ms 604 KB Output is correct
5 Correct 1 ms 600 KB Output is correct
6 Correct 0 ms 600 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 604 KB Output is correct
9 Correct 1 ms 604 KB Output is correct
10 Correct 0 ms 608 KB Output is correct
11 Correct 1 ms 604 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 604 KB Output is correct
14 Correct 2 ms 604 KB Output is correct
15 Correct 2 ms 784 KB Output is correct
16 Correct 2 ms 604 KB Output is correct
17 Correct 2 ms 604 KB Output is correct
18 Correct 2 ms 604 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 2 ms 604 KB Output is correct
21 Correct 2 ms 604 KB Output is correct
22 Correct 137 ms 14696 KB Output is correct
23 Correct 141 ms 15188 KB Output is correct
24 Correct 178 ms 16428 KB Output is correct
25 Correct 274 ms 22360 KB Output is correct
26 Correct 141 ms 14756 KB Output is correct
27 Correct 281 ms 22216 KB Output is correct
28 Correct 276 ms 22356 KB Output is correct
29 Correct 133 ms 13908 KB Output is correct
30 Correct 87 ms 13912 KB Output is correct
31 Correct 101 ms 14624 KB Output is correct
32 Correct 227 ms 21680 KB Output is correct
33 Correct 87 ms 14164 KB Output is correct
34 Correct 1 ms 604 KB Output is correct
35 Correct 0 ms 604 KB Output is correct
36 Correct 0 ms 604 KB Output is correct
37 Correct 1 ms 604 KB Output is correct
38 Correct 2 ms 600 KB Output is correct
39 Correct 2 ms 672 KB Output is correct
40 Correct 2 ms 604 KB Output is correct
41 Correct 87 ms 13908 KB Output is correct
42 Correct 99 ms 14644 KB Output is correct
43 Correct 220 ms 21292 KB Output is correct
44 Correct 86 ms 13968 KB Output is correct
45 Runtime error 1 ms 860 KB Execution killed with signal 11
46 Halted 0 ms 0 KB -