#include <bits/stdc++.h>
using namespace std;
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define sp " "
#define endl "\n"
#define pii pair<int, int>
#define st first
#define nd second
#define pb push_back
#define N 100005
const int INF = 1e9 + 7;
int32_t main(){
//fileio();
fastio();
int n, m, q;
cin>>n>>m>>q;
vector<bitset<N>> dp(n + 5, 0);
vector<int> l(m + 5, 0), r(m + 5, 0), ans(q, 0);
vector<vector<int>> ex(n + 5);
vector<vector<pii>> todo(n + 5);
for (int i = 1; i <= m; i++){
cin>>l[i]>>r[i];
ex[l[i]].pb(r[i]);
}
for (int i = 1; i <= q; i++){
int s, e;
cin>>s>>e;
todo[s].pb({e, i});
}
for (int i = n; i >= 1; i--){
sort(ex[i].begin(), ex[i].end());
int last = i;
bitset<N> all(0);
all = ~all;
for (auto j : ex[i]){
dp[i][j] = 1;
for (int k = last; k < j; k++) all[k] = 0;
while(last <= j){
last++;
//cout<<last<<sp<<all<<endl;
dp[i] |= dp[last] & all;
}
last--;
}
//cout<<i<<": "<<dp[i]<<endl;
for (auto j : todo[i]){
if (dp[i][j.st]) ans[j.nd] = 1;
}
}
for (int i = 1; i <= q; i++) {
if (ans[i]) cout<<"YES\n";
else cout<<"NO\n";
}
cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
600 KB |
Output is correct |
2 |
Correct |
25 ms |
2904 KB |
Output is correct |
3 |
Correct |
4 ms |
2908 KB |
Output is correct |
4 |
Correct |
3 ms |
2908 KB |
Output is correct |
5 |
Execution timed out |
1573 ms |
25180 KB |
Time limit exceeded |
6 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
600 KB |
Output is correct |
2 |
Runtime error |
1 ms |
856 KB |
Execution killed with signal 6 |
3 |
Halted |
0 ms |
0 KB |
- |