Submission #886169

# Submission time Handle Problem Language Result Execution time Memory
886169 2023-12-11T14:19:39 Z vjudge1 Curtains (NOI23_curtains) C++17
0 / 100
789 ms 16212 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 7;
const int inf = 1e9 + 7;
struct SEGT{
	pair < int , int > tree[N];
	SEGT(){
		for(int i = 0;i<N;i++){
			tree[i] = {-inf , inf};
		}
	}
	void update(int ind , int l , int r , int ql , int qr){
		if(l >= ql and r <= qr){
			tree[ind].first = max(tree[ind].first , ql);
			tree[ind].second = min(tree[ind].second , qr);
			return;
		}
		else if(l > qr or r < ql){
			return;
		}
		else{
			int mid = (l+r)/2;
			update(ind*2,l,mid,ql,qr);
			update(ind*2+1,mid+1,r,ql,qr);
			tree[ind].first = max(tree[ind].first , min(tree[ind*2].first , tree[ind*2+1].first));
			tree[ind].second = min(tree[ind].second , max(tree[ind*2].second , tree[ind*2+1].second));
		}
	}
	bool query(int ind , int l , int r , int ql , int qr){
		if(l >= ql and r <= qr){
			return tree[ind].first >= ql and tree[ind].second <= qr;
		}
		else if(l > qr or r < ql){
			return 1;
		}
		else{
			int mid = (l+r)/2;
			return query(ind*2,l,mid,ql,qr) and query(ind*2+1,mid+1,r,ql,qr);
		}
	}
} segt;
void solve(){
	int n,m,q;
	cin >> n >> m >> q;
	for(int i = 0;i<m;i++){
		int x,y;
		cin >> x >> y;
		segt.update(1,1,n,x,y);
	}
	for(int i = 0;i<q;i++){
		int x,y;
		cin >> x >> y;
		cout << (segt.query(1,1,n,x,y) ? "YES" : "NO") << endl;
	}
}
signed main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
	int testcase = 1;//cin >> testcase;
	while(testcase--)solve();
}
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Incorrect 3 ms 8284 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Incorrect 3 ms 8284 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Incorrect 3 ms 8284 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 8024 KB Output is correct
2 Correct 2 ms 8536 KB Output is correct
3 Correct 2 ms 8284 KB Output is correct
4 Correct 2 ms 8280 KB Output is correct
5 Correct 5 ms 8280 KB Output is correct
6 Correct 6 ms 8284 KB Output is correct
7 Correct 5 ms 8280 KB Output is correct
8 Correct 654 ms 10148 KB Output is correct
9 Correct 662 ms 10068 KB Output is correct
10 Correct 789 ms 10160 KB Output is correct
11 Correct 644 ms 10264 KB Output is correct
12 Correct 178 ms 8616 KB Output is correct
13 Correct 183 ms 8508 KB Output is correct
14 Correct 152 ms 8532 KB Output is correct
15 Correct 153 ms 8392 KB Output is correct
16 Correct 159 ms 9044 KB Output is correct
17 Correct 153 ms 8524 KB Output is correct
18 Runtime error 8 ms 16212 KB Execution killed with signal 11
19 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Incorrect 3 ms 8284 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 8024 KB Output is correct
2 Correct 2 ms 8028 KB Output is correct
3 Incorrect 3 ms 8284 KB Output isn't correct
4 Halted 0 ms 0 KB -