This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
#define ll long long
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define REP(i, a, b) for (int i = (a); i >= (b); --i)
#define pi pair<int,int>
#define ple tuple<int,int,int>
#define fi first
#define se second
#define ii make_pair
#define isz(a) ((int)a.size())
#define ALL(a) a.begin(), a.end()
using namespace std;
const int N = 1e6 + 10;
void maximize (int &a, int b) {
a = max(a, b);
}
int n, m, q, res[N];
pi a[N];
vector<pi> ques[N];
vector<int> events[N];
struct STree {
int node[N * 4], lazy[N * 4];
void down (int id, int l, int r) {
if (lazy[id] == 0) return;
maximize(node[id], lazy[id]);
if (l != r) {
maximize(lazy[id*2], lazy[id]);
maximize(lazy[id*2+1], lazy[id]);
}
lazy[id] = 0;
}
void update (int id, int l, int r, int u, int v, int val) {
down(id, l, r);
if (l > v || r < u) return;
if (l >= u && r <= v) {
lazy[id] = val;
down(id, l, r);
return;
}
int mid = l + r >> 1;
update(id*2, l, mid, u, v, val);
update(id*2+1, mid+1, r, u, v, val);
node[id] = min(node[id*2], node[id*2+1]);
}
int get (int id, int l, int r, int u, int v) {
down(id, l, r);
if (l > v || r < u) return 1e9;
if (l >= u && r <= v) return node[id];
int mid = l + r >> 1;
return min(get(id*2,l,mid,u,v),get(id*2+1,mid+1,r,u,v));
}
} st;
int main () {
file("pupil");
ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
cin >> n >> m >> q;
FOR(i,1,m) {
int l,r; cin >> l >> r;
events[r].push_back(l);
}
FOR(i,1,q) {
int l,r; cin >> l >> r;
ques[r].push_back({l, i});
}
FOR(r,1,n) {
for (int l : events[r]) {
st.update(1, 1, n, l, r, l);
}
for (pi it : ques[r]) {
int l = it.fi;
int id = it.se;
if (st.get(1,1,n,l,r) >= l) {
res[id] = true;
}
}
}
FOR(i,1,q) {
cout << (res[i] == true ? "YES\n" : "NO\n");
}
}
Compilation message (stderr)
curtains.cpp: In member function 'void STree::update(int, int, int, int, int, int)':
curtains.cpp:46:25: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
46 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In member function 'int STree::get(int, int, int, int, int)':
curtains.cpp:55:24: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
55 | int mid = l + r >> 1;
| ~~^~~
curtains.cpp: In function 'int main()':
curtains.cpp:2:60: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
2 | #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:61:7: note: in expansion of macro 'file'
61 | file("pupil");
| ^~~~
curtains.cpp:2:94: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
2 | #define file(name) if (fopen (name".inp", "r")) { freopen (name".inp", "r", stdin); freopen (name".out", "w", stdout); }
| ~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
curtains.cpp:61:7: note: in expansion of macro 'file'
61 | file("pupil");
| ^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |