Submission #886040

# Submission time Handle Problem Language Result Execution time Memory
886040 2023-12-11T12:14:56 Z vjudge1 Curtains (NOI23_curtains) C++17
80 / 100
1500 ms 29172 KB
#include <bits/stdc++.h>
using namespace std;
#define tol(bi) (1LL<<((int)(bi)))
typedef long long ll;
constexpr int MOD = 1e9+7;
struct SegTree{
	vector<int> segtree;
	SegTree(int n){
		segtree.resize(tol(ceil(log2(n)+1))-1,-1);
	}
	void dallan(int node){
		if (node*2+1<segtree.size()){
			segtree[node*2+1]=max(segtree[node*2+1],segtree[node]);
			segtree[node*2+2]=max(segtree[node*2+2],segtree[node]);
		}
	}
	void update(int tarl, int tarr, int val, int l = 0, int r = -1, int node = 0){
		if (r==-1) r = segtree.size()/2;
		dallan(node);
		if (l>=tarl && r<=tarr){
			segtree[node]=max(segtree[node],val);
			dallan(node);
			return;
		}
		if (l>tarr || r<tarl) return;
		int mid = l+(r-l)/2;
		update(tarl, tarr, val, l, mid, node*2+1);
		update(tarl, tarr, val, mid+1, r, node*2+2);
		segtree[node]=min(segtree[node*2+1],segtree[node*2+2]);
	}
	int query(int tarl, int tarr, int l = 0, int r = -1, int node = 0){
		if (r==-1) r = segtree.size()/2;
		dallan(node);
		if (l>=tarl && r<=tarr) return segtree[node];
		if (l>tarr || r<tarl) return MOD;
		int mid = l+(r-l)/2;
		int lnode = query(tarl, tarr, l, mid, node*2+1);
		int rnode = query(tarl, tarr, mid+1, r, node*2+2);
		return min(lnode, rnode);
	}
};
int main(){
	int n,m,q;
	cin>>n>>m>>q;
	SegTree segtree(n);
	vector<pair<int,int>> arr(m);
	for (int i = 0; i < m; ++i)
	{
		cin>>arr[i].first>>arr[i].second;
	}
	sort(arr.begin(), arr.end(), [&](pair<int,int> a, pair<int,int> b){
		return a.second<b.second;
	});
	int ind = 0;
	vector<array<int,3>> qarr(q);
	vector<bool> ansarr(q,false);
	for (int i = 0; i < q; ++i)
	{
		cin>>qarr[i][0]>>qarr[i][1];
		qarr[i][2]=i;
	}
	sort(qarr.begin(), qarr.end(), [&](array<int,3> a, array<int,3> b){
		return a[1]<b[1];
	});
	for (int i = 0; i < q; ++i)
	{
		while (ind<m && arr[ind].second<=qarr[i][1]){
			segtree.update(arr[ind].first-1,arr[ind].second-1,arr[ind].first-1);
			ind++;
		}
		if (segtree.query(qarr[i][0]-1,qarr[i][1]-1)>=qarr[i][0]-1) ansarr[qarr[i][2]]=true;
	}
	for (int i = 0; i < q; ++i)
	{
		if (ansarr[i]) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;
	}
}

Compilation message

curtains.cpp: In member function 'void SegTree::dallan(int)':
curtains.cpp:12:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |   if (node*2+1<segtree.size()){
      |       ~~~~~~~~^~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 5 ms 532 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 5 ms 532 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
22 Correct 871 ms 12512 KB Output is correct
23 Correct 824 ms 12760 KB Output is correct
24 Correct 881 ms 14216 KB Output is correct
25 Correct 1199 ms 20788 KB Output is correct
26 Correct 821 ms 12472 KB Output is correct
27 Correct 1189 ms 21120 KB Output is correct
28 Correct 1167 ms 20936 KB Output is correct
29 Correct 820 ms 12180 KB Output is correct
30 Correct 761 ms 11468 KB Output is correct
31 Correct 800 ms 12164 KB Output is correct
32 Correct 1137 ms 19824 KB Output is correct
33 Correct 744 ms 11452 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 5 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 5 ms 348 KB Output is correct
8 Correct 763 ms 11668 KB Output is correct
9 Correct 795 ms 12484 KB Output is correct
10 Correct 1076 ms 19604 KB Output is correct
11 Correct 795 ms 11484 KB Output is correct
12 Correct 270 ms 5500 KB Output is correct
13 Correct 254 ms 5564 KB Output is correct
14 Correct 229 ms 5480 KB Output is correct
15 Correct 254 ms 5604 KB Output is correct
16 Correct 231 ms 5456 KB Output is correct
17 Correct 238 ms 5756 KB Output is correct
18 Correct 1422 ms 26872 KB Output is correct
19 Correct 1389 ms 27412 KB Output is correct
20 Correct 1293 ms 26896 KB Output is correct
21 Correct 1229 ms 26616 KB Output is correct
22 Correct 1265 ms 26584 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 5 ms 532 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
22 Correct 253 ms 4604 KB Output is correct
23 Correct 283 ms 4684 KB Output is correct
24 Correct 284 ms 6080 KB Output is correct
25 Correct 281 ms 5820 KB Output is correct
26 Correct 260 ms 6352 KB Output is correct
27 Correct 256 ms 6140 KB Output is correct
28 Correct 231 ms 4948 KB Output is correct
29 Correct 260 ms 5796 KB Output is correct
30 Correct 291 ms 5968 KB Output is correct
31 Correct 304 ms 5988 KB Output is correct
32 Correct 269 ms 5932 KB Output is correct
33 Correct 282 ms 5952 KB Output is correct
34 Correct 274 ms 5972 KB Output is correct
35 Correct 288 ms 5792 KB Output is correct
36 Correct 276 ms 5972 KB Output is correct
37 Correct 279 ms 5592 KB Output is correct
38 Correct 260 ms 5604 KB Output is correct
39 Correct 284 ms 5456 KB Output is correct
40 Correct 232 ms 5812 KB Output is correct
41 Correct 231 ms 5416 KB Output is correct
42 Correct 230 ms 5580 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 344 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 432 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 5 ms 348 KB Output is correct
14 Correct 5 ms 532 KB Output is correct
15 Correct 5 ms 344 KB Output is correct
16 Correct 5 ms 344 KB Output is correct
17 Correct 5 ms 348 KB Output is correct
18 Correct 4 ms 348 KB Output is correct
19 Correct 4 ms 348 KB Output is correct
20 Correct 5 ms 348 KB Output is correct
21 Correct 5 ms 344 KB Output is correct
22 Correct 871 ms 12512 KB Output is correct
23 Correct 824 ms 12760 KB Output is correct
24 Correct 881 ms 14216 KB Output is correct
25 Correct 1199 ms 20788 KB Output is correct
26 Correct 821 ms 12472 KB Output is correct
27 Correct 1189 ms 21120 KB Output is correct
28 Correct 1167 ms 20936 KB Output is correct
29 Correct 820 ms 12180 KB Output is correct
30 Correct 761 ms 11468 KB Output is correct
31 Correct 800 ms 12164 KB Output is correct
32 Correct 1137 ms 19824 KB Output is correct
33 Correct 744 ms 11452 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 1 ms 348 KB Output is correct
37 Correct 1 ms 348 KB Output is correct
38 Correct 5 ms 348 KB Output is correct
39 Correct 4 ms 348 KB Output is correct
40 Correct 5 ms 348 KB Output is correct
41 Correct 763 ms 11668 KB Output is correct
42 Correct 795 ms 12484 KB Output is correct
43 Correct 1076 ms 19604 KB Output is correct
44 Correct 795 ms 11484 KB Output is correct
45 Correct 270 ms 5500 KB Output is correct
46 Correct 254 ms 5564 KB Output is correct
47 Correct 229 ms 5480 KB Output is correct
48 Correct 254 ms 5604 KB Output is correct
49 Correct 231 ms 5456 KB Output is correct
50 Correct 238 ms 5756 KB Output is correct
51 Correct 1422 ms 26872 KB Output is correct
52 Correct 1389 ms 27412 KB Output is correct
53 Correct 1293 ms 26896 KB Output is correct
54 Correct 1229 ms 26616 KB Output is correct
55 Correct 1265 ms 26584 KB Output is correct
56 Correct 253 ms 4604 KB Output is correct
57 Correct 283 ms 4684 KB Output is correct
58 Correct 284 ms 6080 KB Output is correct
59 Correct 281 ms 5820 KB Output is correct
60 Correct 260 ms 6352 KB Output is correct
61 Correct 256 ms 6140 KB Output is correct
62 Correct 231 ms 4948 KB Output is correct
63 Correct 260 ms 5796 KB Output is correct
64 Correct 291 ms 5968 KB Output is correct
65 Correct 304 ms 5988 KB Output is correct
66 Correct 269 ms 5932 KB Output is correct
67 Correct 282 ms 5952 KB Output is correct
68 Correct 274 ms 5972 KB Output is correct
69 Correct 288 ms 5792 KB Output is correct
70 Correct 276 ms 5972 KB Output is correct
71 Correct 279 ms 5592 KB Output is correct
72 Correct 260 ms 5604 KB Output is correct
73 Correct 284 ms 5456 KB Output is correct
74 Correct 232 ms 5812 KB Output is correct
75 Correct 231 ms 5416 KB Output is correct
76 Correct 230 ms 5580 KB Output is correct
77 Execution timed out 1541 ms 29172 KB Time limit exceeded
78 Halted 0 ms 0 KB -