답안 #886815

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886815 2023-12-13T02:33:53 Z prohacker Curtains (NOI23_curtains) C++14
100 / 100
841 ms 45652 KB
#include <bits/stdc++.h>
#define ll long long
#define ld long double

using namespace std;

const int N = 5e5+10;
const int INF = INT_MAX;
const int mod = 1e9+7;
const string NAME = "solve";

int n,m,t;
pair<int,int> edges[N];
vector<pair<int,int>> events[N];
int ans[N];
int tree[4*N],lazy[4*N];

void down(int id, int l, int r) {
    int &t = lazy[id];
    if(t == 0) {
        return;
    }
    tree[id] = max(tree[id],t);
    if(l < r) {
        lazy[id << 1] = max(lazy[id << 1],t);
        lazy[id << 1 | 1] = max(lazy[id << 1 | 1],t);
    }
    t = 0;
}

void update(int u, int v, int val, int id = 1, int l = 1, int r = n) {
    down(id,l,r);
    if(r < u or v < l) {
        return;
    }
    if(u <= l and r <= v) {
        lazy[id] = val;
        down(id,l,r);
        return;
    }
    int mid = l + r >> 1;
    update(u,v,val,id << 1,l,mid);
    update(u,v,val,id << 1 | 1,mid+1,r);
    tree[id] = min(tree[id << 1],tree[id << 1 | 1]);
}

int get(int u, int v, int id = 1, int l = 1, int r = n) {
    down(id,l,r);
    if(r < u or v < l) {
        return mod;
    }
    if(u <= l and r <= v) {
        return tree[id];
    }
    int mid = l + r >> 1;
    return min(get(u,v,id << 1,l,mid),get(u,v,id << 1 | 1,mid+1,r));
}

signed main()
{
    if (fopen((NAME + ".inp").c_str(), "r")) {
        freopen((NAME + ".inp").c_str(), "r", stdin);
        freopen((NAME + ".out").c_str(), "w", stdout);
    }
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> t;
    for(int i = 1 ; i <= m ; i++) {
        int l,r; cin >> l >> r;
        edges[i] = {r,l};
    }
    for(int i = 1 ; i <= t ; i++) {
        int l,r; cin >> l >> r;
        events[r].push_back({l,i});
    }
    sort(edges+1,edges+m+1);
    for(int i = 1, j = 1 ; i <= n ; i++) {
        while(j <= m and edges[j].first <= i) {
            update(edges[j].second,edges[j].first,edges[j].second);
            j++;
        }
        for(auto p:events[i]) {
            int val = get(p.first,i);
            if(val >= p.first) {
                ans[p.second] = 1;
            }
        }
    }
    for(int i = 1 ; i <= t ; i++) {
        if(ans[i]) {
            cout << "YES" << '\n';
        }
        else {
            cout << "NO" << '\n';
        }
    }
    return 0;
}

Compilation message

curtains.cpp: In function 'void update(int, int, int, int, int, int)':
curtains.cpp:41:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   41 |     int mid = l + r >> 1;
      |               ~~^~~
curtains.cpp: In function 'int get(int, int, int, int, int)':
curtains.cpp:55:17: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   55 |     int mid = l + r >> 1;
      |               ~~^~~
curtains.cpp: In function 'int main()':
curtains.cpp:62:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   62 |         freopen((NAME + ".inp").c_str(), "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:63:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   63 |         freopen((NAME + ".out").c_str(), "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16728 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 5 ms 16892 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 3 ms 14680 KB Output is correct
9 Correct 3 ms 16728 KB Output is correct
10 Correct 3 ms 14680 KB Output is correct
11 Correct 3 ms 16880 KB Output is correct
12 Correct 4 ms 16732 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16728 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 5 ms 16892 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 3 ms 14680 KB Output is correct
9 Correct 3 ms 16728 KB Output is correct
10 Correct 3 ms 14680 KB Output is correct
11 Correct 3 ms 16880 KB Output is correct
12 Correct 4 ms 16732 KB Output is correct
13 Correct 5 ms 16732 KB Output is correct
14 Correct 6 ms 16964 KB Output is correct
15 Correct 5 ms 16732 KB Output is correct
16 Correct 5 ms 16728 KB Output is correct
17 Correct 6 ms 16984 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 14940 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 4 ms 16728 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16728 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 5 ms 16892 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 3 ms 14680 KB Output is correct
9 Correct 3 ms 16728 KB Output is correct
10 Correct 3 ms 14680 KB Output is correct
11 Correct 3 ms 16880 KB Output is correct
12 Correct 4 ms 16732 KB Output is correct
13 Correct 5 ms 16732 KB Output is correct
14 Correct 6 ms 16964 KB Output is correct
15 Correct 5 ms 16732 KB Output is correct
16 Correct 5 ms 16728 KB Output is correct
17 Correct 6 ms 16984 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 14940 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 4 ms 16728 KB Output is correct
22 Correct 183 ms 24680 KB Output is correct
23 Correct 186 ms 24912 KB Output is correct
24 Correct 227 ms 25068 KB Output is correct
25 Correct 394 ms 27216 KB Output is correct
26 Correct 219 ms 24660 KB Output is correct
27 Correct 389 ms 27216 KB Output is correct
28 Correct 393 ms 27256 KB Output is correct
29 Correct 171 ms 23888 KB Output is correct
30 Correct 119 ms 25036 KB Output is correct
31 Correct 138 ms 24940 KB Output is correct
32 Correct 337 ms 27616 KB Output is correct
33 Correct 137 ms 24952 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 16728 KB Output is correct
2 Correct 3 ms 14684 KB Output is correct
3 Correct 3 ms 16732 KB Output is correct
4 Correct 3 ms 14684 KB Output is correct
5 Correct 6 ms 16988 KB Output is correct
6 Correct 6 ms 16988 KB Output is correct
7 Correct 4 ms 14936 KB Output is correct
8 Correct 115 ms 24980 KB Output is correct
9 Correct 137 ms 25168 KB Output is correct
10 Correct 336 ms 27356 KB Output is correct
11 Correct 120 ms 24956 KB Output is correct
12 Correct 110 ms 22280 KB Output is correct
13 Correct 104 ms 22364 KB Output is correct
14 Correct 86 ms 20052 KB Output is correct
15 Correct 82 ms 22096 KB Output is correct
16 Correct 84 ms 20188 KB Output is correct
17 Correct 79 ms 22100 KB Output is correct
18 Correct 708 ms 44920 KB Output is correct
19 Correct 630 ms 44756 KB Output is correct
20 Correct 456 ms 45652 KB Output is correct
21 Correct 482 ms 43508 KB Output is correct
22 Correct 461 ms 43604 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16728 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 5 ms 16892 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 3 ms 14680 KB Output is correct
9 Correct 3 ms 16728 KB Output is correct
10 Correct 3 ms 14680 KB Output is correct
11 Correct 3 ms 16880 KB Output is correct
12 Correct 4 ms 16732 KB Output is correct
13 Correct 5 ms 16732 KB Output is correct
14 Correct 6 ms 16964 KB Output is correct
15 Correct 5 ms 16732 KB Output is correct
16 Correct 5 ms 16728 KB Output is correct
17 Correct 6 ms 16984 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 14940 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 4 ms 16728 KB Output is correct
22 Correct 106 ms 18716 KB Output is correct
23 Correct 102 ms 18740 KB Output is correct
24 Correct 129 ms 21076 KB Output is correct
25 Correct 130 ms 21232 KB Output is correct
26 Correct 102 ms 20816 KB Output is correct
27 Correct 97 ms 21076 KB Output is correct
28 Correct 86 ms 21076 KB Output is correct
29 Correct 90 ms 20820 KB Output is correct
30 Correct 139 ms 21328 KB Output is correct
31 Correct 129 ms 21052 KB Output is correct
32 Correct 114 ms 21208 KB Output is correct
33 Correct 134 ms 21292 KB Output is correct
34 Correct 124 ms 20696 KB Output is correct
35 Correct 118 ms 21072 KB Output is correct
36 Correct 111 ms 21076 KB Output is correct
37 Correct 107 ms 22244 KB Output is correct
38 Correct 109 ms 22416 KB Output is correct
39 Correct 79 ms 20168 KB Output is correct
40 Correct 105 ms 22096 KB Output is correct
41 Correct 81 ms 20144 KB Output is correct
42 Correct 79 ms 22100 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 16728 KB Output is correct
2 Correct 3 ms 16732 KB Output is correct
3 Correct 5 ms 16892 KB Output is correct
4 Correct 3 ms 16732 KB Output is correct
5 Correct 3 ms 16732 KB Output is correct
6 Correct 3 ms 16732 KB Output is correct
7 Correct 4 ms 16732 KB Output is correct
8 Correct 3 ms 14680 KB Output is correct
9 Correct 3 ms 16728 KB Output is correct
10 Correct 3 ms 14680 KB Output is correct
11 Correct 3 ms 16880 KB Output is correct
12 Correct 4 ms 16732 KB Output is correct
13 Correct 5 ms 16732 KB Output is correct
14 Correct 6 ms 16964 KB Output is correct
15 Correct 5 ms 16732 KB Output is correct
16 Correct 5 ms 16728 KB Output is correct
17 Correct 6 ms 16984 KB Output is correct
18 Correct 4 ms 16988 KB Output is correct
19 Correct 4 ms 14940 KB Output is correct
20 Correct 4 ms 16732 KB Output is correct
21 Correct 4 ms 16728 KB Output is correct
22 Correct 183 ms 24680 KB Output is correct
23 Correct 186 ms 24912 KB Output is correct
24 Correct 227 ms 25068 KB Output is correct
25 Correct 394 ms 27216 KB Output is correct
26 Correct 219 ms 24660 KB Output is correct
27 Correct 389 ms 27216 KB Output is correct
28 Correct 393 ms 27256 KB Output is correct
29 Correct 171 ms 23888 KB Output is correct
30 Correct 119 ms 25036 KB Output is correct
31 Correct 138 ms 24940 KB Output is correct
32 Correct 337 ms 27616 KB Output is correct
33 Correct 137 ms 24952 KB Output is correct
34 Correct 4 ms 16728 KB Output is correct
35 Correct 3 ms 14684 KB Output is correct
36 Correct 3 ms 16732 KB Output is correct
37 Correct 3 ms 14684 KB Output is correct
38 Correct 6 ms 16988 KB Output is correct
39 Correct 6 ms 16988 KB Output is correct
40 Correct 4 ms 14936 KB Output is correct
41 Correct 115 ms 24980 KB Output is correct
42 Correct 137 ms 25168 KB Output is correct
43 Correct 336 ms 27356 KB Output is correct
44 Correct 120 ms 24956 KB Output is correct
45 Correct 110 ms 22280 KB Output is correct
46 Correct 104 ms 22364 KB Output is correct
47 Correct 86 ms 20052 KB Output is correct
48 Correct 82 ms 22096 KB Output is correct
49 Correct 84 ms 20188 KB Output is correct
50 Correct 79 ms 22100 KB Output is correct
51 Correct 708 ms 44920 KB Output is correct
52 Correct 630 ms 44756 KB Output is correct
53 Correct 456 ms 45652 KB Output is correct
54 Correct 482 ms 43508 KB Output is correct
55 Correct 461 ms 43604 KB Output is correct
56 Correct 106 ms 18716 KB Output is correct
57 Correct 102 ms 18740 KB Output is correct
58 Correct 129 ms 21076 KB Output is correct
59 Correct 130 ms 21232 KB Output is correct
60 Correct 102 ms 20816 KB Output is correct
61 Correct 97 ms 21076 KB Output is correct
62 Correct 86 ms 21076 KB Output is correct
63 Correct 90 ms 20820 KB Output is correct
64 Correct 139 ms 21328 KB Output is correct
65 Correct 129 ms 21052 KB Output is correct
66 Correct 114 ms 21208 KB Output is correct
67 Correct 134 ms 21292 KB Output is correct
68 Correct 124 ms 20696 KB Output is correct
69 Correct 118 ms 21072 KB Output is correct
70 Correct 111 ms 21076 KB Output is correct
71 Correct 107 ms 22244 KB Output is correct
72 Correct 109 ms 22416 KB Output is correct
73 Correct 79 ms 20168 KB Output is correct
74 Correct 105 ms 22096 KB Output is correct
75 Correct 81 ms 20144 KB Output is correct
76 Correct 79 ms 22100 KB Output is correct
77 Correct 789 ms 40276 KB Output is correct
78 Correct 841 ms 39292 KB Output is correct
79 Correct 553 ms 38992 KB Output is correct
80 Correct 608 ms 38540 KB Output is correct
81 Correct 565 ms 38344 KB Output is correct
82 Correct 570 ms 38480 KB Output is correct
83 Correct 786 ms 40532 KB Output is correct
84 Correct 835 ms 38996 KB Output is correct
85 Correct 702 ms 40976 KB Output is correct
86 Correct 718 ms 39344 KB Output is correct
87 Correct 677 ms 39760 KB Output is correct
88 Correct 582 ms 39760 KB Output is correct