답안 #933219

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933219 2024-02-25T09:31:46 Z browntoad Curtains (NOI23_curtains) C++14
100 / 100
939 ms 61040 KB
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define int ll
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define REP1(i, n) FOR(i, 1, n+1)
#define pii pair<int, int>
#define pip pair<int, pii>
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) (int)((x).size())
#define f first
#define s second
#define pb push_back
#define IOS() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define endl '\n'

const ll maxn = 5e5+5;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;

vector<int> seg(4*maxn), tag(4*maxn);
void push(int x, int l, int r){
    seg[x] = max(seg[x], tag[x]);
    if (l < r){
        tag[x+x] = max(tag[x], tag[x+x]);
        tag[x+x+1] = max(tag[x], tag[x+x+1]);
    }
    tag[x] = 0;
}
int query(int l, int r, int nl, int nr, int x){
    push(x, nl, nr);
    if (l > nr || r < nl) return inf;
    if (l <= nl && nr <= r) return seg[x];
    int mid = nl+nr>>1;
    return min(query(l, r, nl, mid, x+x), query(l, r, mid+1, nr, x+x+1));
}
void modify(int l, int r, int nl, int nr, int v, int x){
    if (l > nr || r < nl){
        push(x, nl, nr);
        return;
    }
    if (l <= nl && nr <= r){
        tag[x] = max(tag[x], v);
        push(x, nl, nr);
        return;
    }
    push(x, nl, nr);
    int mid = nl+nr>>1;
    modify(l, r, nl, mid, v, x+x);
    modify(l, r, mid+1, nr, v, x+x+1);
    seg[x] = min(seg[x+x], seg[x+x+1]);
}
int n, m, q;
bool cmp(pip a, pip b){
    return a.s.s < b.s.s;
}
signed main(){
    IOS();
    cin>>n>>m>>q;
    vector<pip> mo(m), quer(q);
    vector<int> ans(q);
    REP(i, m){
        cin>>mo[i].s.f>>mo[i].s.s;
        mo[i].f = i;
    }
    REP(i, q){
        cin>>quer[i].s.f>>quer[i].s.s;
        quer[i].f = i;
    }
    sort(ALL(mo), cmp); sort(ALL(quer), cmp);

    int ptr = 0;
    REP(i, q){
        while(ptr < m && mo[ptr].s.s <= quer[i].s.s){
            modify(mo[ptr].s.f, mo[ptr].s.s, 1, n, mo[ptr].s.f, 1);
            ptr++;
        }
        if (query(quer[i].s.f, quer[i].s.s, 1, n, 1) >= quer[i].s.f){
            ans[quer[i].f] = 1;
        }
        else ans[quer[i].f] = 0;
    }
    REP(i, q) cout<<(ans[i]?"YES":"NO")<<endl;


}



Compilation message

curtains.cpp: In function 'long long int query(long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:35:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |     int mid = nl+nr>>1;
      |               ~~^~~
curtains.cpp: In function 'void modify(long long int, long long int, long long int, long long int, long long int, long long int)':
curtains.cpp:49:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   49 |     int mid = nl+nr>>1;
      |               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31580 KB Output is correct
2 Correct 6 ms 31580 KB Output is correct
3 Correct 5 ms 31576 KB Output is correct
4 Correct 5 ms 31588 KB Output is correct
5 Correct 6 ms 31580 KB Output is correct
6 Correct 5 ms 31580 KB Output is correct
7 Correct 7 ms 31580 KB Output is correct
8 Correct 6 ms 31580 KB Output is correct
9 Correct 6 ms 31580 KB Output is correct
10 Correct 5 ms 31580 KB Output is correct
11 Correct 6 ms 31556 KB Output is correct
12 Correct 5 ms 31580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31580 KB Output is correct
2 Correct 6 ms 31580 KB Output is correct
3 Correct 5 ms 31576 KB Output is correct
4 Correct 5 ms 31588 KB Output is correct
5 Correct 6 ms 31580 KB Output is correct
6 Correct 5 ms 31580 KB Output is correct
7 Correct 7 ms 31580 KB Output is correct
8 Correct 6 ms 31580 KB Output is correct
9 Correct 6 ms 31580 KB Output is correct
10 Correct 5 ms 31580 KB Output is correct
11 Correct 6 ms 31556 KB Output is correct
12 Correct 5 ms 31580 KB Output is correct
13 Correct 9 ms 31836 KB Output is correct
14 Correct 7 ms 31836 KB Output is correct
15 Correct 7 ms 31692 KB Output is correct
16 Correct 7 ms 31836 KB Output is correct
17 Correct 7 ms 31836 KB Output is correct
18 Correct 7 ms 31836 KB Output is correct
19 Correct 7 ms 31852 KB Output is correct
20 Correct 7 ms 31836 KB Output is correct
21 Correct 9 ms 31792 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31580 KB Output is correct
2 Correct 6 ms 31580 KB Output is correct
3 Correct 5 ms 31576 KB Output is correct
4 Correct 5 ms 31588 KB Output is correct
5 Correct 6 ms 31580 KB Output is correct
6 Correct 5 ms 31580 KB Output is correct
7 Correct 7 ms 31580 KB Output is correct
8 Correct 6 ms 31580 KB Output is correct
9 Correct 6 ms 31580 KB Output is correct
10 Correct 5 ms 31580 KB Output is correct
11 Correct 6 ms 31556 KB Output is correct
12 Correct 5 ms 31580 KB Output is correct
13 Correct 9 ms 31836 KB Output is correct
14 Correct 7 ms 31836 KB Output is correct
15 Correct 7 ms 31692 KB Output is correct
16 Correct 7 ms 31836 KB Output is correct
17 Correct 7 ms 31836 KB Output is correct
18 Correct 7 ms 31836 KB Output is correct
19 Correct 7 ms 31852 KB Output is correct
20 Correct 7 ms 31836 KB Output is correct
21 Correct 9 ms 31792 KB Output is correct
22 Correct 289 ms 48976 KB Output is correct
23 Correct 256 ms 49448 KB Output is correct
24 Correct 319 ms 51560 KB Output is correct
25 Correct 545 ms 60916 KB Output is correct
26 Correct 272 ms 49076 KB Output is correct
27 Correct 513 ms 60956 KB Output is correct
28 Correct 533 ms 61040 KB Output is correct
29 Correct 244 ms 49068 KB Output is correct
30 Correct 204 ms 49232 KB Output is correct
31 Correct 222 ms 50496 KB Output is correct
32 Correct 444 ms 61012 KB Output is correct
33 Correct 204 ms 49452 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31580 KB Output is correct
2 Correct 5 ms 31580 KB Output is correct
3 Correct 5 ms 31580 KB Output is correct
4 Correct 6 ms 31580 KB Output is correct
5 Correct 7 ms 31836 KB Output is correct
6 Correct 7 ms 31832 KB Output is correct
7 Correct 7 ms 31836 KB Output is correct
8 Correct 194 ms 49232 KB Output is correct
9 Correct 240 ms 50388 KB Output is correct
10 Correct 422 ms 60956 KB Output is correct
11 Correct 193 ms 49464 KB Output is correct
12 Correct 159 ms 37512 KB Output is correct
13 Correct 128 ms 37716 KB Output is correct
14 Correct 101 ms 37756 KB Output is correct
15 Correct 103 ms 37500 KB Output is correct
16 Correct 110 ms 37500 KB Output is correct
17 Correct 116 ms 37496 KB Output is correct
18 Correct 713 ms 60704 KB Output is correct
19 Correct 847 ms 60752 KB Output is correct
20 Correct 554 ms 60500 KB Output is correct
21 Correct 545 ms 60440 KB Output is correct
22 Correct 557 ms 60448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31580 KB Output is correct
2 Correct 6 ms 31580 KB Output is correct
3 Correct 5 ms 31576 KB Output is correct
4 Correct 5 ms 31588 KB Output is correct
5 Correct 6 ms 31580 KB Output is correct
6 Correct 5 ms 31580 KB Output is correct
7 Correct 7 ms 31580 KB Output is correct
8 Correct 6 ms 31580 KB Output is correct
9 Correct 6 ms 31580 KB Output is correct
10 Correct 5 ms 31580 KB Output is correct
11 Correct 6 ms 31556 KB Output is correct
12 Correct 5 ms 31580 KB Output is correct
13 Correct 9 ms 31836 KB Output is correct
14 Correct 7 ms 31836 KB Output is correct
15 Correct 7 ms 31692 KB Output is correct
16 Correct 7 ms 31836 KB Output is correct
17 Correct 7 ms 31836 KB Output is correct
18 Correct 7 ms 31836 KB Output is correct
19 Correct 7 ms 31852 KB Output is correct
20 Correct 7 ms 31836 KB Output is correct
21 Correct 9 ms 31792 KB Output is correct
22 Correct 123 ms 37504 KB Output is correct
23 Correct 120 ms 37460 KB Output is correct
24 Correct 145 ms 37456 KB Output is correct
25 Correct 145 ms 37456 KB Output is correct
26 Correct 132 ms 37460 KB Output is correct
27 Correct 147 ms 37456 KB Output is correct
28 Correct 96 ms 36180 KB Output is correct
29 Correct 119 ms 37264 KB Output is correct
30 Correct 146 ms 37516 KB Output is correct
31 Correct 148 ms 37456 KB Output is correct
32 Correct 135 ms 37516 KB Output is correct
33 Correct 125 ms 37460 KB Output is correct
34 Correct 138 ms 37500 KB Output is correct
35 Correct 144 ms 37496 KB Output is correct
36 Correct 135 ms 37452 KB Output is correct
37 Correct 123 ms 37516 KB Output is correct
38 Correct 122 ms 37496 KB Output is correct
39 Correct 100 ms 37460 KB Output is correct
40 Correct 101 ms 37500 KB Output is correct
41 Correct 100 ms 37460 KB Output is correct
42 Correct 103 ms 37456 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 6 ms 31580 KB Output is correct
2 Correct 6 ms 31580 KB Output is correct
3 Correct 5 ms 31576 KB Output is correct
4 Correct 5 ms 31588 KB Output is correct
5 Correct 6 ms 31580 KB Output is correct
6 Correct 5 ms 31580 KB Output is correct
7 Correct 7 ms 31580 KB Output is correct
8 Correct 6 ms 31580 KB Output is correct
9 Correct 6 ms 31580 KB Output is correct
10 Correct 5 ms 31580 KB Output is correct
11 Correct 6 ms 31556 KB Output is correct
12 Correct 5 ms 31580 KB Output is correct
13 Correct 9 ms 31836 KB Output is correct
14 Correct 7 ms 31836 KB Output is correct
15 Correct 7 ms 31692 KB Output is correct
16 Correct 7 ms 31836 KB Output is correct
17 Correct 7 ms 31836 KB Output is correct
18 Correct 7 ms 31836 KB Output is correct
19 Correct 7 ms 31852 KB Output is correct
20 Correct 7 ms 31836 KB Output is correct
21 Correct 9 ms 31792 KB Output is correct
22 Correct 289 ms 48976 KB Output is correct
23 Correct 256 ms 49448 KB Output is correct
24 Correct 319 ms 51560 KB Output is correct
25 Correct 545 ms 60916 KB Output is correct
26 Correct 272 ms 49076 KB Output is correct
27 Correct 513 ms 60956 KB Output is correct
28 Correct 533 ms 61040 KB Output is correct
29 Correct 244 ms 49068 KB Output is correct
30 Correct 204 ms 49232 KB Output is correct
31 Correct 222 ms 50496 KB Output is correct
32 Correct 444 ms 61012 KB Output is correct
33 Correct 204 ms 49452 KB Output is correct
34 Correct 6 ms 31580 KB Output is correct
35 Correct 5 ms 31580 KB Output is correct
36 Correct 5 ms 31580 KB Output is correct
37 Correct 6 ms 31580 KB Output is correct
38 Correct 7 ms 31836 KB Output is correct
39 Correct 7 ms 31832 KB Output is correct
40 Correct 7 ms 31836 KB Output is correct
41 Correct 194 ms 49232 KB Output is correct
42 Correct 240 ms 50388 KB Output is correct
43 Correct 422 ms 60956 KB Output is correct
44 Correct 193 ms 49464 KB Output is correct
45 Correct 159 ms 37512 KB Output is correct
46 Correct 128 ms 37716 KB Output is correct
47 Correct 101 ms 37756 KB Output is correct
48 Correct 103 ms 37500 KB Output is correct
49 Correct 110 ms 37500 KB Output is correct
50 Correct 116 ms 37496 KB Output is correct
51 Correct 713 ms 60704 KB Output is correct
52 Correct 847 ms 60752 KB Output is correct
53 Correct 554 ms 60500 KB Output is correct
54 Correct 545 ms 60440 KB Output is correct
55 Correct 557 ms 60448 KB Output is correct
56 Correct 123 ms 37504 KB Output is correct
57 Correct 120 ms 37460 KB Output is correct
58 Correct 145 ms 37456 KB Output is correct
59 Correct 145 ms 37456 KB Output is correct
60 Correct 132 ms 37460 KB Output is correct
61 Correct 147 ms 37456 KB Output is correct
62 Correct 96 ms 36180 KB Output is correct
63 Correct 119 ms 37264 KB Output is correct
64 Correct 146 ms 37516 KB Output is correct
65 Correct 148 ms 37456 KB Output is correct
66 Correct 135 ms 37516 KB Output is correct
67 Correct 125 ms 37460 KB Output is correct
68 Correct 138 ms 37500 KB Output is correct
69 Correct 144 ms 37496 KB Output is correct
70 Correct 135 ms 37452 KB Output is correct
71 Correct 123 ms 37516 KB Output is correct
72 Correct 122 ms 37496 KB Output is correct
73 Correct 100 ms 37460 KB Output is correct
74 Correct 101 ms 37500 KB Output is correct
75 Correct 100 ms 37460 KB Output is correct
76 Correct 103 ms 37456 KB Output is correct
77 Correct 923 ms 60700 KB Output is correct
78 Correct 939 ms 60700 KB Output is correct
79 Correct 731 ms 61008 KB Output is correct
80 Correct 694 ms 61008 KB Output is correct
81 Correct 700 ms 59988 KB Output is correct
82 Correct 694 ms 60404 KB Output is correct
83 Correct 926 ms 60636 KB Output is correct
84 Correct 916 ms 60696 KB Output is correct
85 Correct 781 ms 60756 KB Output is correct
86 Correct 797 ms 60696 KB Output is correct
87 Correct 787 ms 60700 KB Output is correct
88 Correct 762 ms 60696 KB Output is correct