Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
63 lines (63 loc) · 1.38 KB

File metadata and controls

63 lines (63 loc) · 1.38 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int, int>
#define ff first
#define ss second
int guardHeights[100005];
int queryHeights[100005];
int invalid[100005];
int ans[100005];
struct node{
bool query;
int timer;
bool start;
int id;
node(bool query, int timer, bool start, int id) : query(query), timer(timer), start(start), id(id) { }
};
bool cmp(node a, node b){
if(a.timer != b.timer)
return a.timer < b.timer;
else
return a.query < b.query;
}
int main(){
int i,j,h,c,q,s,e,max_h;
scanf("%d %d %d", &h, &c, &q);
vector<node> timeSortedQueries;
priority_queue<ii> pq;
ii tp;
for(i = 0; i < c; i++){
scanf("%d %d %d", &guardHeights[i], &s, &e);
timeSortedQueries.push_back(node(0, s, 1, i));
timeSortedQueries.push_back(node(0, e + 1, 0, i));
}
for(i = 0; i < q; i++){
scanf("%d %d", &queryHeights[i], &s);
timeSortedQueries.push_back(node(1, s, 0, i));
}
sort(timeSortedQueries.begin(), timeSortedQueries.end(), cmp);
for(auto el : timeSortedQueries){
if(!el.query){
if(el.start)
pq.push({guardHeights[el.id], el.id});
else
invalid[el.id] = 1;
}
else{
max_h = 0;
while(!pq.empty()){
tp = pq.top();
if(!invalid[tp.ss]){
max_h = tp.ff;
break;
}
else
pq.pop();
}
ans[el.id] = (queryHeights[el.id] > max_h);
}
}
for(i = 0; i < q; i++)
printf("%s\n", ans[i] ? "YES" : "NO");
return 0;
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.