#include <bits/stdc++.h>
#define pii pair<int, int>
#define F first
#define S second
using namespace std;
int ans[300005];
int x[300005], t[300005], a[300005], b[300005];
set<pii>sa[405], sb[405];
multiset<int>sx[405];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int n, k, q;
cin>>n>>k>>q;
for(int i=1;i<=n;i++){
cin>>x[i]>>t[i]>>a[i]>>b[i];
sa[t[i]].insert({a[i], i});
}
vector<pair<pii, int>>queries;
for(int i=1;i<=q;i++){
int l, y;
cin>>l>>y;
queries.push_back({{y, l}, i});
}
sort(queries.begin(), queries.end());
for(auto p:queries){
int y=p.F.F, l=p.F.S, idx=p.S;
int fans=0;
for(int i=1;i<=k;i++){
while(!sa[i].empty()){
auto it=sa[i].begin();
if(it->F <= y){
sb[i].insert({b[it->S], it->S});
sx[i].insert(x[it->S]);
}
else break;
sa[i].erase(it);
}
while(!sb[i].empty()){
auto it=sb[i].begin();
if(it->F < y){
sx[i].erase(sx[i].find(x[it->S]));
sb[i].erase({b[it->S], it->S});
}
else break;
}
int cur=1e9;
auto it=sx[i].lower_bound(l);
if(it!=sx[i].end()) cur=min(cur, abs(*it - l));
if(!sx[i].empty() && it!=sx[i].begin()){
it--;
cur=min(cur, abs(*it - l));
}
fans=max(fans, cur);
}
if(fans==1e9) fans=-1;
ans[idx]=fans;
}
for(int i=1;i<=q;i++){
cout<<ans[i]<<"\n";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
512 KB |
Output is correct |
16 |
Correct |
2 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
2 ms |
512 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
1 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
536 KB |
Output is correct |
30 |
Correct |
1 ms |
512 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
512 KB |
Output is correct |
16 |
Correct |
2 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
2 ms |
512 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
1 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
536 KB |
Output is correct |
30 |
Correct |
1 ms |
512 KB |
Output is correct |
31 |
Correct |
2857 ms |
11332 KB |
Output is correct |
32 |
Correct |
130 ms |
6892 KB |
Output is correct |
33 |
Correct |
261 ms |
8940 KB |
Output is correct |
34 |
Correct |
2004 ms |
9200 KB |
Output is correct |
35 |
Correct |
1132 ms |
11376 KB |
Output is correct |
36 |
Correct |
278 ms |
11124 KB |
Output is correct |
37 |
Correct |
225 ms |
8536 KB |
Output is correct |
38 |
Correct |
136 ms |
8428 KB |
Output is correct |
39 |
Correct |
111 ms |
8432 KB |
Output is correct |
40 |
Correct |
112 ms |
8472 KB |
Output is correct |
41 |
Correct |
373 ms |
8788 KB |
Output is correct |
42 |
Correct |
500 ms |
8684 KB |
Output is correct |
43 |
Correct |
785 ms |
10992 KB |
Output is correct |
44 |
Correct |
316 ms |
8740 KB |
Output is correct |
45 |
Correct |
153 ms |
8816 KB |
Output is correct |
46 |
Correct |
83 ms |
8688 KB |
Output is correct |
47 |
Correct |
93 ms |
8168 KB |
Output is correct |
48 |
Correct |
73 ms |
8168 KB |
Output is correct |
49 |
Correct |
106 ms |
8304 KB |
Output is correct |
50 |
Correct |
284 ms |
8432 KB |
Output is correct |
51 |
Correct |
84 ms |
8304 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
1 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
512 KB |
Output is correct |
16 |
Correct |
2 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
2 ms |
512 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
1 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
536 KB |
Output is correct |
30 |
Correct |
1 ms |
512 KB |
Output is correct |
31 |
Correct |
2857 ms |
11332 KB |
Output is correct |
32 |
Correct |
130 ms |
6892 KB |
Output is correct |
33 |
Correct |
261 ms |
8940 KB |
Output is correct |
34 |
Correct |
2004 ms |
9200 KB |
Output is correct |
35 |
Correct |
1132 ms |
11376 KB |
Output is correct |
36 |
Correct |
278 ms |
11124 KB |
Output is correct |
37 |
Correct |
225 ms |
8536 KB |
Output is correct |
38 |
Correct |
136 ms |
8428 KB |
Output is correct |
39 |
Correct |
111 ms |
8432 KB |
Output is correct |
40 |
Correct |
112 ms |
8472 KB |
Output is correct |
41 |
Correct |
373 ms |
8788 KB |
Output is correct |
42 |
Correct |
500 ms |
8684 KB |
Output is correct |
43 |
Correct |
785 ms |
10992 KB |
Output is correct |
44 |
Correct |
316 ms |
8740 KB |
Output is correct |
45 |
Correct |
153 ms |
8816 KB |
Output is correct |
46 |
Correct |
83 ms |
8688 KB |
Output is correct |
47 |
Correct |
93 ms |
8168 KB |
Output is correct |
48 |
Correct |
73 ms |
8168 KB |
Output is correct |
49 |
Correct |
106 ms |
8304 KB |
Output is correct |
50 |
Correct |
284 ms |
8432 KB |
Output is correct |
51 |
Correct |
84 ms |
8304 KB |
Output is correct |
52 |
Runtime error |
2 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
53 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
512 KB |
Output is correct |
6 |
Correct |
2 ms |
488 KB |
Output is correct |
7 |
Correct |
3 ms |
512 KB |
Output is correct |
8 |
Correct |
2 ms |
512 KB |
Output is correct |
9 |
Correct |
3 ms |
512 KB |
Output is correct |
10 |
Correct |
1 ms |
512 KB |
Output is correct |
11 |
Correct |
1 ms |
512 KB |
Output is correct |
12 |
Correct |
1 ms |
512 KB |
Output is correct |
13 |
Correct |
1 ms |
512 KB |
Output is correct |
14 |
Correct |
1 ms |
512 KB |
Output is correct |
15 |
Correct |
2 ms |
512 KB |
Output is correct |
16 |
Correct |
2 ms |
512 KB |
Output is correct |
17 |
Correct |
1 ms |
512 KB |
Output is correct |
18 |
Correct |
2 ms |
512 KB |
Output is correct |
19 |
Correct |
2 ms |
512 KB |
Output is correct |
20 |
Correct |
2 ms |
512 KB |
Output is correct |
21 |
Correct |
2 ms |
512 KB |
Output is correct |
22 |
Correct |
3 ms |
512 KB |
Output is correct |
23 |
Correct |
2 ms |
512 KB |
Output is correct |
24 |
Correct |
2 ms |
512 KB |
Output is correct |
25 |
Correct |
1 ms |
512 KB |
Output is correct |
26 |
Correct |
2 ms |
512 KB |
Output is correct |
27 |
Correct |
1 ms |
512 KB |
Output is correct |
28 |
Correct |
2 ms |
512 KB |
Output is correct |
29 |
Correct |
2 ms |
536 KB |
Output is correct |
30 |
Correct |
1 ms |
512 KB |
Output is correct |
31 |
Correct |
2857 ms |
11332 KB |
Output is correct |
32 |
Correct |
130 ms |
6892 KB |
Output is correct |
33 |
Correct |
261 ms |
8940 KB |
Output is correct |
34 |
Correct |
2004 ms |
9200 KB |
Output is correct |
35 |
Correct |
1132 ms |
11376 KB |
Output is correct |
36 |
Correct |
278 ms |
11124 KB |
Output is correct |
37 |
Correct |
225 ms |
8536 KB |
Output is correct |
38 |
Correct |
136 ms |
8428 KB |
Output is correct |
39 |
Correct |
111 ms |
8432 KB |
Output is correct |
40 |
Correct |
112 ms |
8472 KB |
Output is correct |
41 |
Correct |
373 ms |
8788 KB |
Output is correct |
42 |
Correct |
500 ms |
8684 KB |
Output is correct |
43 |
Correct |
785 ms |
10992 KB |
Output is correct |
44 |
Correct |
316 ms |
8740 KB |
Output is correct |
45 |
Correct |
153 ms |
8816 KB |
Output is correct |
46 |
Correct |
83 ms |
8688 KB |
Output is correct |
47 |
Correct |
93 ms |
8168 KB |
Output is correct |
48 |
Correct |
73 ms |
8168 KB |
Output is correct |
49 |
Correct |
106 ms |
8304 KB |
Output is correct |
50 |
Correct |
284 ms |
8432 KB |
Output is correct |
51 |
Correct |
84 ms |
8304 KB |
Output is correct |
52 |
Runtime error |
2 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
53 |
Halted |
0 ms |
0 KB |
- |