답안 #886049

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
886049 2023-12-11T12:20:39 Z vjudge1 Curtains (NOI23_curtains) C++17
80 / 100
1500 ms 16168 KB
#include <bits/stdc++.h>
using namespace std;
#define tol(bi) (1LL<<((int)(bi)))
typedef long long ll;
constexpr int MOD = 1e9+7;
constexpr int MAXN = 2000005;
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;
		}
		int mid = l+(r-l)/2;
		if (mid>=tarl) update(tarl, tarr, val, l, mid, node*2+1);
		if (mid+1<=tarr) 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];
		int mid = l+(r-l)/2;
		int lnode = MOD;
		int rnode = MOD;
		if (mid>=tarl) lnode = query(tarl, tarr, l, mid, node*2+1);
		if (mid+1<=tarr) 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:13:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   if (node*2+1<segtree.size()){
      |       ~~~~~~~~^~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 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 344 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 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 344 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 348 KB Output is correct
15 Correct 5 ms 484 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 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 344 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 348 KB Output is correct
15 Correct 5 ms 484 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
22 Correct 810 ms 7916 KB Output is correct
23 Correct 841 ms 8276 KB Output is correct
24 Correct 894 ms 9300 KB Output is correct
25 Correct 1154 ms 12348 KB Output is correct
26 Correct 877 ms 8100 KB Output is correct
27 Correct 1154 ms 12192 KB Output is correct
28 Correct 1135 ms 12072 KB Output is correct
29 Correct 803 ms 7920 KB Output is correct
30 Correct 758 ms 8316 KB Output is correct
31 Correct 786 ms 8924 KB Output is correct
32 Correct 1098 ms 12220 KB Output is correct
33 Correct 749 ms 8388 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 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 4 ms 348 KB Output is correct
6 Correct 4 ms 348 KB Output is correct
7 Correct 4 ms 348 KB Output is correct
8 Correct 739 ms 8196 KB Output is correct
9 Correct 781 ms 8516 KB Output is correct
10 Correct 1095 ms 12304 KB Output is correct
11 Correct 814 ms 8432 KB Output is correct
12 Correct 246 ms 3668 KB Output is correct
13 Correct 254 ms 3952 KB Output is correct
14 Correct 226 ms 3656 KB Output is correct
15 Correct 232 ms 3516 KB Output is correct
16 Correct 251 ms 3716 KB Output is correct
17 Correct 230 ms 3692 KB Output is correct
18 Correct 1406 ms 15904 KB Output is correct
19 Correct 1386 ms 15928 KB Output is correct
20 Correct 1185 ms 16056 KB Output is correct
21 Correct 1232 ms 15796 KB Output is correct
22 Correct 1191 ms 15784 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 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 344 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 348 KB Output is correct
15 Correct 5 ms 484 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
22 Correct 249 ms 2888 KB Output is correct
23 Correct 244 ms 2888 KB Output is correct
24 Correct 283 ms 3704 KB Output is correct
25 Correct 274 ms 3664 KB Output is correct
26 Correct 254 ms 3640 KB Output is correct
27 Correct 251 ms 3644 KB Output is correct
28 Correct 215 ms 3300 KB Output is correct
29 Correct 248 ms 3684 KB Output is correct
30 Correct 289 ms 3528 KB Output is correct
31 Correct 298 ms 3728 KB Output is correct
32 Correct 270 ms 3664 KB Output is correct
33 Correct 276 ms 3756 KB Output is correct
34 Correct 301 ms 3664 KB Output is correct
35 Correct 292 ms 3516 KB Output is correct
36 Correct 271 ms 3668 KB Output is correct
37 Correct 260 ms 3776 KB Output is correct
38 Correct 273 ms 4084 KB Output is correct
39 Correct 234 ms 3680 KB Output is correct
40 Correct 227 ms 3680 KB Output is correct
41 Correct 236 ms 3620 KB Output is correct
42 Correct 232 ms 3532 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 344 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 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 344 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 348 KB Output is correct
15 Correct 5 ms 484 KB Output is correct
16 Correct 5 ms 348 KB Output is correct
17 Correct 4 ms 348 KB Output is correct
18 Correct 4 ms 344 KB Output is correct
19 Correct 5 ms 604 KB Output is correct
20 Correct 4 ms 348 KB Output is correct
21 Correct 5 ms 348 KB Output is correct
22 Correct 810 ms 7916 KB Output is correct
23 Correct 841 ms 8276 KB Output is correct
24 Correct 894 ms 9300 KB Output is correct
25 Correct 1154 ms 12348 KB Output is correct
26 Correct 877 ms 8100 KB Output is correct
27 Correct 1154 ms 12192 KB Output is correct
28 Correct 1135 ms 12072 KB Output is correct
29 Correct 803 ms 7920 KB Output is correct
30 Correct 758 ms 8316 KB Output is correct
31 Correct 786 ms 8924 KB Output is correct
32 Correct 1098 ms 12220 KB Output is correct
33 Correct 749 ms 8388 KB Output is correct
34 Correct 1 ms 344 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 4 ms 348 KB Output is correct
39 Correct 4 ms 348 KB Output is correct
40 Correct 4 ms 348 KB Output is correct
41 Correct 739 ms 8196 KB Output is correct
42 Correct 781 ms 8516 KB Output is correct
43 Correct 1095 ms 12304 KB Output is correct
44 Correct 814 ms 8432 KB Output is correct
45 Correct 246 ms 3668 KB Output is correct
46 Correct 254 ms 3952 KB Output is correct
47 Correct 226 ms 3656 KB Output is correct
48 Correct 232 ms 3516 KB Output is correct
49 Correct 251 ms 3716 KB Output is correct
50 Correct 230 ms 3692 KB Output is correct
51 Correct 1406 ms 15904 KB Output is correct
52 Correct 1386 ms 15928 KB Output is correct
53 Correct 1185 ms 16056 KB Output is correct
54 Correct 1232 ms 15796 KB Output is correct
55 Correct 1191 ms 15784 KB Output is correct
56 Correct 249 ms 2888 KB Output is correct
57 Correct 244 ms 2888 KB Output is correct
58 Correct 283 ms 3704 KB Output is correct
59 Correct 274 ms 3664 KB Output is correct
60 Correct 254 ms 3640 KB Output is correct
61 Correct 251 ms 3644 KB Output is correct
62 Correct 215 ms 3300 KB Output is correct
63 Correct 248 ms 3684 KB Output is correct
64 Correct 289 ms 3528 KB Output is correct
65 Correct 298 ms 3728 KB Output is correct
66 Correct 270 ms 3664 KB Output is correct
67 Correct 276 ms 3756 KB Output is correct
68 Correct 301 ms 3664 KB Output is correct
69 Correct 292 ms 3516 KB Output is correct
70 Correct 271 ms 3668 KB Output is correct
71 Correct 260 ms 3776 KB Output is correct
72 Correct 273 ms 4084 KB Output is correct
73 Correct 234 ms 3680 KB Output is correct
74 Correct 227 ms 3680 KB Output is correct
75 Correct 236 ms 3620 KB Output is correct
76 Correct 232 ms 3532 KB Output is correct
77 Execution timed out 1520 ms 16168 KB Time limit exceeded
78 Halted 0 ms 0 KB -