#include <bits/stdc++.h>
#define pb push_back
#define all(aa) aa.begin(), aa.end()
using namespace std;
struct BIT{
int n;
vector<int> cnt, fen;
BIT(vector<int> a) : cnt(a){
n = a.size();
fen.resize(n);
for(int i = 0; i < n; i++){
if(cnt[i]) upd(i);
}
}
void upd(int pos){
for(int j = pos; j < n; j = j|(j+1)){
fen[j] += 1;
}
}
int find(int pos){
int ret = 0;
for(int j = pos; j >= 0; j = (j & (j + 1)) - 1)
ret += fen[j];
return ret;
}
int find(int l, int r){
return find(r) - find(l - 1);
}
};
int main(){
int n, m, q;
cin >> n >> m >> q;
vector<int> cnt(n);
vector<int> ok(n);
vector<int> mn(n, n+1);
for(int i = 0; i < m; i++){
int a, b;
cin >> a >> b;
--a, --b;
mn[b] = min(mn[b], a);
if(a == 0) cnt[b] = 1;
}
BIT fen(cnt);
for(int i = 0; i < n; i++){
if(fen.find(mn[i]-1, i) > 0){
ok[i] = 1;
fen.upd(i);
}
}
for(int i = 0; i < q; i++){
int a, b;
cin >> a >> b;
--a, --b;
cout << (ok[b] ? "YES" : "NO") << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 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 |
604 KB |
Output is correct |
5 |
Correct |
6 ms |
348 KB |
Output is correct |
6 |
Correct |
4 ms |
344 KB |
Output is correct |
7 |
Correct |
4 ms |
348 KB |
Output is correct |
8 |
Correct |
729 ms |
4528 KB |
Output is correct |
9 |
Correct |
735 ms |
4724 KB |
Output is correct |
10 |
Correct |
880 ms |
6728 KB |
Output is correct |
11 |
Correct |
720 ms |
4448 KB |
Output is correct |
12 |
Correct |
188 ms |
4032 KB |
Output is correct |
13 |
Correct |
203 ms |
4176 KB |
Output is correct |
14 |
Correct |
196 ms |
4136 KB |
Output is correct |
15 |
Correct |
187 ms |
4104 KB |
Output is correct |
16 |
Correct |
186 ms |
4044 KB |
Output is correct |
17 |
Correct |
188 ms |
4100 KB |
Output is correct |
18 |
Correct |
993 ms |
18040 KB |
Output is correct |
19 |
Correct |
985 ms |
18196 KB |
Output is correct |
20 |
Correct |
1033 ms |
17780 KB |
Output is correct |
21 |
Correct |
1008 ms |
17712 KB |
Output is correct |
22 |
Correct |
996 ms |
17840 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Incorrect |
1 ms |
348 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |