답안 #933326

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
933326 2024-02-25T13:32:32 Z browntoad Curtains (NOI23_curtains) C++14
100 / 100
865 ms 38768 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 = 2147483647;
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 'int query(int, int, int, int, int)':
curtains.cpp:35:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   35 |     int mid = nl+nr>>1;
      |               ~~^~~
curtains.cpp: In function 'void modify(int, int, int, int, int, int)':
curtains.cpp:49:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   49 |     int mid = nl+nr>>1;
      |               ~~^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 4 ms 15960 KB Output is correct
4 Correct 4 ms 15964 KB Output is correct
5 Correct 4 ms 16004 KB Output is correct
6 Correct 4 ms 16124 KB Output is correct
7 Correct 4 ms 15964 KB Output is correct
8 Correct 4 ms 15896 KB Output is correct
9 Correct 4 ms 15960 KB Output is correct
10 Correct 4 ms 15964 KB Output is correct
11 Correct 3 ms 15964 KB Output is correct
12 Correct 3 ms 15960 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 4 ms 15960 KB Output is correct
4 Correct 4 ms 15964 KB Output is correct
5 Correct 4 ms 16004 KB Output is correct
6 Correct 4 ms 16124 KB Output is correct
7 Correct 4 ms 15964 KB Output is correct
8 Correct 4 ms 15896 KB Output is correct
9 Correct 4 ms 15960 KB Output is correct
10 Correct 4 ms 15964 KB Output is correct
11 Correct 3 ms 15964 KB Output is correct
12 Correct 3 ms 15960 KB Output is correct
13 Correct 6 ms 16036 KB Output is correct
14 Correct 5 ms 16216 KB Output is correct
15 Correct 7 ms 16220 KB Output is correct
16 Correct 6 ms 16220 KB Output is correct
17 Correct 5 ms 16220 KB Output is correct
18 Correct 6 ms 15964 KB Output is correct
19 Correct 5 ms 16220 KB Output is correct
20 Correct 6 ms 16012 KB Output is correct
21 Correct 5 ms 16220 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 4 ms 15960 KB Output is correct
4 Correct 4 ms 15964 KB Output is correct
5 Correct 4 ms 16004 KB Output is correct
6 Correct 4 ms 16124 KB Output is correct
7 Correct 4 ms 15964 KB Output is correct
8 Correct 4 ms 15896 KB Output is correct
9 Correct 4 ms 15960 KB Output is correct
10 Correct 4 ms 15964 KB Output is correct
11 Correct 3 ms 15964 KB Output is correct
12 Correct 3 ms 15960 KB Output is correct
13 Correct 6 ms 16036 KB Output is correct
14 Correct 5 ms 16216 KB Output is correct
15 Correct 7 ms 16220 KB Output is correct
16 Correct 6 ms 16220 KB Output is correct
17 Correct 5 ms 16220 KB Output is correct
18 Correct 6 ms 15964 KB Output is correct
19 Correct 5 ms 16220 KB Output is correct
20 Correct 6 ms 16012 KB Output is correct
21 Correct 5 ms 16220 KB Output is correct
22 Correct 259 ms 28052 KB Output is correct
23 Correct 248 ms 28752 KB Output is correct
24 Correct 295 ms 30188 KB Output is correct
25 Correct 478 ms 36464 KB Output is correct
26 Correct 241 ms 28496 KB Output is correct
27 Correct 482 ms 36580 KB Output is correct
28 Correct 476 ms 36436 KB Output is correct
29 Correct 267 ms 28020 KB Output is correct
30 Correct 180 ms 27848 KB Output is correct
31 Correct 196 ms 28628 KB Output is correct
32 Correct 411 ms 35952 KB Output is correct
33 Correct 190 ms 27892 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 16132 KB Output is correct
3 Correct 4 ms 15964 KB Output is correct
4 Correct 4 ms 15964 KB Output is correct
5 Correct 5 ms 16220 KB Output is correct
6 Correct 4 ms 16140 KB Output is correct
7 Correct 5 ms 16220 KB Output is correct
8 Correct 178 ms 27692 KB Output is correct
9 Correct 198 ms 29000 KB Output is correct
10 Correct 414 ms 36144 KB Output is correct
11 Correct 182 ms 27892 KB Output is correct
12 Correct 119 ms 20300 KB Output is correct
13 Correct 120 ms 20380 KB Output is correct
14 Correct 96 ms 20380 KB Output is correct
15 Correct 98 ms 20308 KB Output is correct
16 Correct 96 ms 20332 KB Output is correct
17 Correct 101 ms 20724 KB Output is correct
18 Correct 650 ms 37204 KB Output is correct
19 Correct 649 ms 37456 KB Output is correct
20 Correct 510 ms 36976 KB Output is correct
21 Correct 523 ms 37188 KB Output is correct
22 Correct 526 ms 37076 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 4 ms 15960 KB Output is correct
4 Correct 4 ms 15964 KB Output is correct
5 Correct 4 ms 16004 KB Output is correct
6 Correct 4 ms 16124 KB Output is correct
7 Correct 4 ms 15964 KB Output is correct
8 Correct 4 ms 15896 KB Output is correct
9 Correct 4 ms 15960 KB Output is correct
10 Correct 4 ms 15964 KB Output is correct
11 Correct 3 ms 15964 KB Output is correct
12 Correct 3 ms 15960 KB Output is correct
13 Correct 6 ms 16036 KB Output is correct
14 Correct 5 ms 16216 KB Output is correct
15 Correct 7 ms 16220 KB Output is correct
16 Correct 6 ms 16220 KB Output is correct
17 Correct 5 ms 16220 KB Output is correct
18 Correct 6 ms 15964 KB Output is correct
19 Correct 5 ms 16220 KB Output is correct
20 Correct 6 ms 16012 KB Output is correct
21 Correct 5 ms 16220 KB Output is correct
22 Correct 117 ms 20436 KB Output is correct
23 Correct 117 ms 20308 KB Output is correct
24 Correct 140 ms 20564 KB Output is correct
25 Correct 142 ms 20640 KB Output is correct
26 Correct 117 ms 20820 KB Output is correct
27 Correct 122 ms 20920 KB Output is correct
28 Correct 95 ms 19792 KB Output is correct
29 Correct 112 ms 20564 KB Output is correct
30 Correct 144 ms 20816 KB Output is correct
31 Correct 143 ms 20560 KB Output is correct
32 Correct 125 ms 20640 KB Output is correct
33 Correct 118 ms 20564 KB Output is correct
34 Correct 135 ms 20900 KB Output is correct
35 Correct 139 ms 20640 KB Output is correct
36 Correct 131 ms 20592 KB Output is correct
37 Correct 121 ms 20388 KB Output is correct
38 Correct 119 ms 20308 KB Output is correct
39 Correct 98 ms 20384 KB Output is correct
40 Correct 97 ms 20328 KB Output is correct
41 Correct 97 ms 20308 KB Output is correct
42 Correct 96 ms 20304 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 15960 KB Output is correct
2 Correct 3 ms 15964 KB Output is correct
3 Correct 4 ms 15960 KB Output is correct
4 Correct 4 ms 15964 KB Output is correct
5 Correct 4 ms 16004 KB Output is correct
6 Correct 4 ms 16124 KB Output is correct
7 Correct 4 ms 15964 KB Output is correct
8 Correct 4 ms 15896 KB Output is correct
9 Correct 4 ms 15960 KB Output is correct
10 Correct 4 ms 15964 KB Output is correct
11 Correct 3 ms 15964 KB Output is correct
12 Correct 3 ms 15960 KB Output is correct
13 Correct 6 ms 16036 KB Output is correct
14 Correct 5 ms 16216 KB Output is correct
15 Correct 7 ms 16220 KB Output is correct
16 Correct 6 ms 16220 KB Output is correct
17 Correct 5 ms 16220 KB Output is correct
18 Correct 6 ms 15964 KB Output is correct
19 Correct 5 ms 16220 KB Output is correct
20 Correct 6 ms 16012 KB Output is correct
21 Correct 5 ms 16220 KB Output is correct
22 Correct 259 ms 28052 KB Output is correct
23 Correct 248 ms 28752 KB Output is correct
24 Correct 295 ms 30188 KB Output is correct
25 Correct 478 ms 36464 KB Output is correct
26 Correct 241 ms 28496 KB Output is correct
27 Correct 482 ms 36580 KB Output is correct
28 Correct 476 ms 36436 KB Output is correct
29 Correct 267 ms 28020 KB Output is correct
30 Correct 180 ms 27848 KB Output is correct
31 Correct 196 ms 28628 KB Output is correct
32 Correct 411 ms 35952 KB Output is correct
33 Correct 190 ms 27892 KB Output is correct
34 Correct 4 ms 15960 KB Output is correct
35 Correct 3 ms 16132 KB Output is correct
36 Correct 4 ms 15964 KB Output is correct
37 Correct 4 ms 15964 KB Output is correct
38 Correct 5 ms 16220 KB Output is correct
39 Correct 4 ms 16140 KB Output is correct
40 Correct 5 ms 16220 KB Output is correct
41 Correct 178 ms 27692 KB Output is correct
42 Correct 198 ms 29000 KB Output is correct
43 Correct 414 ms 36144 KB Output is correct
44 Correct 182 ms 27892 KB Output is correct
45 Correct 119 ms 20300 KB Output is correct
46 Correct 120 ms 20380 KB Output is correct
47 Correct 96 ms 20380 KB Output is correct
48 Correct 98 ms 20308 KB Output is correct
49 Correct 96 ms 20332 KB Output is correct
50 Correct 101 ms 20724 KB Output is correct
51 Correct 650 ms 37204 KB Output is correct
52 Correct 649 ms 37456 KB Output is correct
53 Correct 510 ms 36976 KB Output is correct
54 Correct 523 ms 37188 KB Output is correct
55 Correct 526 ms 37076 KB Output is correct
56 Correct 117 ms 20436 KB Output is correct
57 Correct 117 ms 20308 KB Output is correct
58 Correct 140 ms 20564 KB Output is correct
59 Correct 142 ms 20640 KB Output is correct
60 Correct 117 ms 20820 KB Output is correct
61 Correct 122 ms 20920 KB Output is correct
62 Correct 95 ms 19792 KB Output is correct
63 Correct 112 ms 20564 KB Output is correct
64 Correct 144 ms 20816 KB Output is correct
65 Correct 143 ms 20560 KB Output is correct
66 Correct 125 ms 20640 KB Output is correct
67 Correct 118 ms 20564 KB Output is correct
68 Correct 135 ms 20900 KB Output is correct
69 Correct 139 ms 20640 KB Output is correct
70 Correct 131 ms 20592 KB Output is correct
71 Correct 121 ms 20388 KB Output is correct
72 Correct 119 ms 20308 KB Output is correct
73 Correct 98 ms 20384 KB Output is correct
74 Correct 97 ms 20328 KB Output is correct
75 Correct 97 ms 20308 KB Output is correct
76 Correct 96 ms 20304 KB Output is correct
77 Correct 805 ms 38492 KB Output is correct
78 Correct 794 ms 38424 KB Output is correct
79 Correct 637 ms 38768 KB Output is correct
80 Correct 647 ms 38768 KB Output is correct
81 Correct 643 ms 37940 KB Output is correct
82 Correct 649 ms 37888 KB Output is correct
83 Correct 824 ms 38272 KB Output is correct
84 Correct 865 ms 38220 KB Output is correct
85 Correct 723 ms 38352 KB Output is correct
86 Correct 769 ms 38512 KB Output is correct
87 Correct 746 ms 37744 KB Output is correct
88 Correct 683 ms 38256 KB Output is correct