Submission #1009187

# Submission time Handle Problem Language Result Execution time Memory
1009187 2024-06-27T09:50:44 Z Khanhcsp2 Curtains (NOI23_curtains) C++14
100 / 100
928 ms 88148 KB
#include<bits/stdc++.h>
#define el '\n'
#define fi first
#define sc second
#define int ll
#define pii pair<int, int>
#define all(v) v.begin(), v.end()
using namespace std;
using ll=long long;
using ull=unsigned long long;
using ld=long double;
const int mod=1e9+7;
const int N=5e5+11;
int n, m, q, l, r, nod[4*N], lazy[4*N], ans[N];
vector<int> rr[N];
vector<pii> qq[N];
void down(int id, int l, int r)
{
    lazy[id*2]=max(lazy[id*2], lazy[id]);
    lazy[id*2+1]=max(lazy[id*2+1], lazy[id]);

    nod[id*2]=max(nod[id*2], lazy[id*2]);
    nod[id*2+1]=max(nod[id*2+1], lazy[id*2+1]);
}
void update(int id, int l, int r, int u, int v, int val)
{
    if(r<u || v<l) return;
    if(u<=l && r<=v)
    {
        lazy[id]=max(lazy[id], val);
        nod[id]=max(nod[id], val);
        return;
    }
    down(id, l, r);
    int mid=(l+r)/2;
    update(id*2, l, mid, u, v, val);
    update(id*2+1, mid+1, r, u, v, val);
    nod[id]=min(nod[id*2], nod[id*2+1]);
}
int get(int id, int l, int r, int u, int v)
{
    if(r<u || v<l) return 1e9;
    if(u<=l && r<=v) return nod[id];
    down(id, l, r);
    int mid=(l+r)/2;
    return min(get(id*2, l, mid, u, v), get(id*2+1, mid+1, r, u, v));
}
void sol()
{
    cin >> n >> m >> q;
    for(int i=1;i<=m;i++)
    {
        cin >> l >> r;
        rr[r].push_back(l);
    }
    for(int i=1;i<=q;i++)
    {
        cin >> l >> r;
        qq[r].push_back({l, i});
    }
    for(int r=1;r<=n;r++)
    {
        for(int l:rr[r]) update(1, 1, n, l, r, l);
        for(auto [l, id]:qq[r])
        {
            if(get(1, 1, n, l, r)>=l) ans[id]=1;
        }
    }
    for(int i=1;i<=q;i++)
    {
        if(ans[i]) cout << "YES" << el;
        else cout << "NO" << el;
    }
}
signed main()
{
//    freopen("divisor.INP", "r", stdin);
//    freopen("divisor.OUT", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t=1;
    //cin >> t;
    while(t--)
    {
        sol();
    }
}

Compilation message

curtains.cpp: In function 'void sol()':
curtains.cpp:64:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   64 |         for(auto [l, id]:qq[r])
      |                  ^
# Verdict Execution time Memory Grader output
1 Correct 4 ms 25180 KB Output is correct
2 Correct 3 ms 25180 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 4 ms 25180 KB Output is correct
5 Correct 4 ms 25216 KB Output is correct
6 Correct 4 ms 25176 KB Output is correct
7 Correct 4 ms 25180 KB Output is correct
8 Correct 4 ms 25180 KB Output is correct
9 Correct 5 ms 25180 KB Output is correct
10 Correct 5 ms 25180 KB Output is correct
11 Correct 5 ms 25232 KB Output is correct
12 Correct 5 ms 25176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 25180 KB Output is correct
2 Correct 3 ms 25180 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 4 ms 25180 KB Output is correct
5 Correct 4 ms 25216 KB Output is correct
6 Correct 4 ms 25176 KB Output is correct
7 Correct 4 ms 25180 KB Output is correct
8 Correct 4 ms 25180 KB Output is correct
9 Correct 5 ms 25180 KB Output is correct
10 Correct 5 ms 25180 KB Output is correct
11 Correct 5 ms 25232 KB Output is correct
12 Correct 5 ms 25176 KB Output is correct
13 Correct 6 ms 25324 KB Output is correct
14 Correct 6 ms 25436 KB Output is correct
15 Correct 6 ms 25436 KB Output is correct
16 Correct 6 ms 25360 KB Output is correct
17 Correct 5 ms 25432 KB Output is correct
18 Correct 6 ms 25436 KB Output is correct
19 Correct 6 ms 25436 KB Output is correct
20 Correct 5 ms 25436 KB Output is correct
21 Correct 6 ms 25272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 25180 KB Output is correct
2 Correct 3 ms 25180 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 4 ms 25180 KB Output is correct
5 Correct 4 ms 25216 KB Output is correct
6 Correct 4 ms 25176 KB Output is correct
7 Correct 4 ms 25180 KB Output is correct
8 Correct 4 ms 25180 KB Output is correct
9 Correct 5 ms 25180 KB Output is correct
10 Correct 5 ms 25180 KB Output is correct
11 Correct 5 ms 25232 KB Output is correct
12 Correct 5 ms 25176 KB Output is correct
13 Correct 6 ms 25324 KB Output is correct
14 Correct 6 ms 25436 KB Output is correct
15 Correct 6 ms 25436 KB Output is correct
16 Correct 6 ms 25360 KB Output is correct
17 Correct 5 ms 25432 KB Output is correct
18 Correct 6 ms 25436 KB Output is correct
19 Correct 6 ms 25436 KB Output is correct
20 Correct 5 ms 25436 KB Output is correct
21 Correct 6 ms 25272 KB Output is correct
22 Correct 166 ms 45652 KB Output is correct
23 Correct 183 ms 46136 KB Output is correct
24 Correct 187 ms 48296 KB Output is correct
25 Correct 303 ms 56060 KB Output is correct
26 Correct 159 ms 45980 KB Output is correct
27 Correct 291 ms 56132 KB Output is correct
28 Correct 303 ms 56144 KB Output is correct
29 Correct 148 ms 44288 KB Output is correct
30 Correct 125 ms 45472 KB Output is correct
31 Correct 129 ms 46672 KB Output is correct
32 Correct 249 ms 55636 KB Output is correct
33 Correct 108 ms 45648 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 25180 KB Output is correct
2 Correct 4 ms 25180 KB Output is correct
3 Correct 5 ms 25180 KB Output is correct
4 Correct 4 ms 25180 KB Output is correct
5 Correct 5 ms 25468 KB Output is correct
6 Correct 5 ms 25436 KB Output is correct
7 Correct 6 ms 25436 KB Output is correct
8 Correct 120 ms 45548 KB Output is correct
9 Correct 133 ms 46676 KB Output is correct
10 Correct 271 ms 55592 KB Output is correct
11 Correct 127 ms 45704 KB Output is correct
12 Correct 103 ms 36600 KB Output is correct
13 Correct 103 ms 36692 KB Output is correct
14 Correct 79 ms 36704 KB Output is correct
15 Correct 73 ms 36432 KB Output is correct
16 Correct 74 ms 36688 KB Output is correct
17 Correct 79 ms 36432 KB Output is correct
18 Correct 654 ms 82404 KB Output is correct
19 Correct 587 ms 82600 KB Output is correct
20 Correct 582 ms 82256 KB Output is correct
21 Correct 510 ms 79700 KB Output is correct
22 Correct 486 ms 80976 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 25180 KB Output is correct
2 Correct 3 ms 25180 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 4 ms 25180 KB Output is correct
5 Correct 4 ms 25216 KB Output is correct
6 Correct 4 ms 25176 KB Output is correct
7 Correct 4 ms 25180 KB Output is correct
8 Correct 4 ms 25180 KB Output is correct
9 Correct 5 ms 25180 KB Output is correct
10 Correct 5 ms 25180 KB Output is correct
11 Correct 5 ms 25232 KB Output is correct
12 Correct 5 ms 25176 KB Output is correct
13 Correct 6 ms 25324 KB Output is correct
14 Correct 6 ms 25436 KB Output is correct
15 Correct 6 ms 25436 KB Output is correct
16 Correct 6 ms 25360 KB Output is correct
17 Correct 5 ms 25432 KB Output is correct
18 Correct 6 ms 25436 KB Output is correct
19 Correct 6 ms 25436 KB Output is correct
20 Correct 5 ms 25436 KB Output is correct
21 Correct 6 ms 25272 KB Output is correct
22 Correct 81 ms 31788 KB Output is correct
23 Correct 104 ms 31904 KB Output is correct
24 Correct 127 ms 36468 KB Output is correct
25 Correct 155 ms 36548 KB Output is correct
26 Correct 112 ms 37744 KB Output is correct
27 Correct 136 ms 37716 KB Output is correct
28 Correct 87 ms 35308 KB Output is correct
29 Correct 127 ms 37164 KB Output is correct
30 Correct 144 ms 36392 KB Output is correct
31 Correct 128 ms 36436 KB Output is correct
32 Correct 146 ms 36776 KB Output is correct
33 Correct 115 ms 36948 KB Output is correct
34 Correct 114 ms 36432 KB Output is correct
35 Correct 121 ms 36368 KB Output is correct
36 Correct 119 ms 36692 KB Output is correct
37 Correct 113 ms 36752 KB Output is correct
38 Correct 124 ms 36648 KB Output is correct
39 Correct 126 ms 36736 KB Output is correct
40 Correct 88 ms 36436 KB Output is correct
41 Correct 103 ms 36748 KB Output is correct
42 Correct 95 ms 36436 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 25180 KB Output is correct
2 Correct 3 ms 25180 KB Output is correct
3 Correct 4 ms 25180 KB Output is correct
4 Correct 4 ms 25180 KB Output is correct
5 Correct 4 ms 25216 KB Output is correct
6 Correct 4 ms 25176 KB Output is correct
7 Correct 4 ms 25180 KB Output is correct
8 Correct 4 ms 25180 KB Output is correct
9 Correct 5 ms 25180 KB Output is correct
10 Correct 5 ms 25180 KB Output is correct
11 Correct 5 ms 25232 KB Output is correct
12 Correct 5 ms 25176 KB Output is correct
13 Correct 6 ms 25324 KB Output is correct
14 Correct 6 ms 25436 KB Output is correct
15 Correct 6 ms 25436 KB Output is correct
16 Correct 6 ms 25360 KB Output is correct
17 Correct 5 ms 25432 KB Output is correct
18 Correct 6 ms 25436 KB Output is correct
19 Correct 6 ms 25436 KB Output is correct
20 Correct 5 ms 25436 KB Output is correct
21 Correct 6 ms 25272 KB Output is correct
22 Correct 166 ms 45652 KB Output is correct
23 Correct 183 ms 46136 KB Output is correct
24 Correct 187 ms 48296 KB Output is correct
25 Correct 303 ms 56060 KB Output is correct
26 Correct 159 ms 45980 KB Output is correct
27 Correct 291 ms 56132 KB Output is correct
28 Correct 303 ms 56144 KB Output is correct
29 Correct 148 ms 44288 KB Output is correct
30 Correct 125 ms 45472 KB Output is correct
31 Correct 129 ms 46672 KB Output is correct
32 Correct 249 ms 55636 KB Output is correct
33 Correct 108 ms 45648 KB Output is correct
34 Correct 4 ms 25180 KB Output is correct
35 Correct 4 ms 25180 KB Output is correct
36 Correct 5 ms 25180 KB Output is correct
37 Correct 4 ms 25180 KB Output is correct
38 Correct 5 ms 25468 KB Output is correct
39 Correct 5 ms 25436 KB Output is correct
40 Correct 6 ms 25436 KB Output is correct
41 Correct 120 ms 45548 KB Output is correct
42 Correct 133 ms 46676 KB Output is correct
43 Correct 271 ms 55592 KB Output is correct
44 Correct 127 ms 45704 KB Output is correct
45 Correct 103 ms 36600 KB Output is correct
46 Correct 103 ms 36692 KB Output is correct
47 Correct 79 ms 36704 KB Output is correct
48 Correct 73 ms 36432 KB Output is correct
49 Correct 74 ms 36688 KB Output is correct
50 Correct 79 ms 36432 KB Output is correct
51 Correct 654 ms 82404 KB Output is correct
52 Correct 587 ms 82600 KB Output is correct
53 Correct 582 ms 82256 KB Output is correct
54 Correct 510 ms 79700 KB Output is correct
55 Correct 486 ms 80976 KB Output is correct
56 Correct 81 ms 31788 KB Output is correct
57 Correct 104 ms 31904 KB Output is correct
58 Correct 127 ms 36468 KB Output is correct
59 Correct 155 ms 36548 KB Output is correct
60 Correct 112 ms 37744 KB Output is correct
61 Correct 136 ms 37716 KB Output is correct
62 Correct 87 ms 35308 KB Output is correct
63 Correct 127 ms 37164 KB Output is correct
64 Correct 144 ms 36392 KB Output is correct
65 Correct 128 ms 36436 KB Output is correct
66 Correct 146 ms 36776 KB Output is correct
67 Correct 115 ms 36948 KB Output is correct
68 Correct 114 ms 36432 KB Output is correct
69 Correct 121 ms 36368 KB Output is correct
70 Correct 119 ms 36692 KB Output is correct
71 Correct 113 ms 36752 KB Output is correct
72 Correct 124 ms 36648 KB Output is correct
73 Correct 126 ms 36736 KB Output is correct
74 Correct 88 ms 36436 KB Output is correct
75 Correct 103 ms 36748 KB Output is correct
76 Correct 95 ms 36436 KB Output is correct
77 Correct 914 ms 82168 KB Output is correct
78 Correct 928 ms 82044 KB Output is correct
79 Correct 718 ms 88148 KB Output is correct
80 Correct 773 ms 87960 KB Output is correct
81 Correct 717 ms 85840 KB Output is correct
82 Correct 679 ms 86988 KB Output is correct
83 Correct 864 ms 82260 KB Output is correct
84 Correct 877 ms 82100 KB Output is correct
85 Correct 769 ms 83028 KB Output is correct
86 Correct 731 ms 81236 KB Output is correct
87 Correct 740 ms 80720 KB Output is correct
88 Correct 744 ms 86096 KB Output is correct