#include <bits/stdc++.h>
using namespace std;
#define int long long
int ans[300001];
map<int,vector<tuple<int,int,int>>> queries;
multiset<int> curr[300001];
int32_t main(){
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
int n,k,q;
cin >> n >> k >> q;
for(int i=1;i<=n;i++){
int x,t,a,b;cin>>x>>t>>a>>b;
queries[a].emplace_back(1,x,t);
queries[b+1].emplace_back(0,x,t);
}
for(int i=1;i<=q;i++){
int l,y;cin>>l>>y;
queries[y].emplace_back(2,l,i);
}
for(int i=1;i<=k;i++)curr[i].insert(1e9);
for(int i=1;i<=k;i++)curr[i].insert(-1e9);
for(auto&[tim,vec]:queries){
for(auto&[type,loc,idx]:vec){
if(type==0){
curr[idx].erase(curr[idx].find(loc));
} else if(type==1){
curr[idx].insert(loc);
} else {
for(int i=1;i<=k;i++){
auto iter = curr[i].lower_bound(loc);
int myans = *iter-loc;
iter--;
myans = min(myans,loc-*iter);
ans[idx] = max(ans[idx],myans);
}
}
}
}
for(int i=1;i<=q;i++)cout<<(ans[i]>1e8 ? -1 : ans[i])<<'\n';
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
3 ms |
14940 KB |
Output is correct |
3 |
Correct |
4 ms |
14940 KB |
Output is correct |
4 |
Correct |
4 ms |
14940 KB |
Output is correct |
5 |
Correct |
4 ms |
14940 KB |
Output is correct |
6 |
Correct |
4 ms |
14940 KB |
Output is correct |
7 |
Correct |
4 ms |
15196 KB |
Output is correct |
8 |
Correct |
4 ms |
14940 KB |
Output is correct |
9 |
Correct |
5 ms |
15196 KB |
Output is correct |
10 |
Correct |
4 ms |
14940 KB |
Output is correct |
11 |
Correct |
4 ms |
14940 KB |
Output is correct |
12 |
Correct |
4 ms |
15016 KB |
Output is correct |
13 |
Correct |
4 ms |
15012 KB |
Output is correct |
14 |
Correct |
4 ms |
14940 KB |
Output is correct |
15 |
Correct |
4 ms |
14940 KB |
Output is correct |
16 |
Correct |
4 ms |
15196 KB |
Output is correct |
17 |
Correct |
4 ms |
15016 KB |
Output is correct |
18 |
Correct |
6 ms |
15196 KB |
Output is correct |
19 |
Correct |
6 ms |
15196 KB |
Output is correct |
20 |
Correct |
4 ms |
14940 KB |
Output is correct |
21 |
Correct |
4 ms |
14940 KB |
Output is correct |
22 |
Correct |
5 ms |
15196 KB |
Output is correct |
23 |
Correct |
4 ms |
14940 KB |
Output is correct |
24 |
Correct |
4 ms |
14940 KB |
Output is correct |
25 |
Correct |
4 ms |
14940 KB |
Output is correct |
26 |
Correct |
4 ms |
15104 KB |
Output is correct |
27 |
Correct |
4 ms |
14936 KB |
Output is correct |
28 |
Correct |
3 ms |
14936 KB |
Output is correct |
29 |
Correct |
4 ms |
14940 KB |
Output is correct |
30 |
Correct |
4 ms |
14936 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
3 ms |
14940 KB |
Output is correct |
3 |
Correct |
4 ms |
14940 KB |
Output is correct |
4 |
Correct |
4 ms |
14940 KB |
Output is correct |
5 |
Correct |
4 ms |
14940 KB |
Output is correct |
6 |
Correct |
4 ms |
14940 KB |
Output is correct |
7 |
Correct |
4 ms |
15196 KB |
Output is correct |
8 |
Correct |
4 ms |
14940 KB |
Output is correct |
9 |
Correct |
5 ms |
15196 KB |
Output is correct |
10 |
Correct |
4 ms |
14940 KB |
Output is correct |
11 |
Correct |
4 ms |
14940 KB |
Output is correct |
12 |
Correct |
4 ms |
15016 KB |
Output is correct |
13 |
Correct |
4 ms |
15012 KB |
Output is correct |
14 |
Correct |
4 ms |
14940 KB |
Output is correct |
15 |
Correct |
4 ms |
14940 KB |
Output is correct |
16 |
Correct |
4 ms |
15196 KB |
Output is correct |
17 |
Correct |
4 ms |
15016 KB |
Output is correct |
18 |
Correct |
6 ms |
15196 KB |
Output is correct |
19 |
Correct |
6 ms |
15196 KB |
Output is correct |
20 |
Correct |
4 ms |
14940 KB |
Output is correct |
21 |
Correct |
4 ms |
14940 KB |
Output is correct |
22 |
Correct |
5 ms |
15196 KB |
Output is correct |
23 |
Correct |
4 ms |
14940 KB |
Output is correct |
24 |
Correct |
4 ms |
14940 KB |
Output is correct |
25 |
Correct |
4 ms |
14940 KB |
Output is correct |
26 |
Correct |
4 ms |
15104 KB |
Output is correct |
27 |
Correct |
4 ms |
14936 KB |
Output is correct |
28 |
Correct |
3 ms |
14936 KB |
Output is correct |
29 |
Correct |
4 ms |
14940 KB |
Output is correct |
30 |
Correct |
4 ms |
14936 KB |
Output is correct |
31 |
Correct |
1666 ms |
41196 KB |
Output is correct |
32 |
Correct |
59 ms |
21992 KB |
Output is correct |
33 |
Correct |
247 ms |
38884 KB |
Output is correct |
34 |
Correct |
1314 ms |
38988 KB |
Output is correct |
35 |
Correct |
761 ms |
40784 KB |
Output is correct |
36 |
Correct |
258 ms |
40528 KB |
Output is correct |
37 |
Correct |
182 ms |
38224 KB |
Output is correct |
38 |
Correct |
158 ms |
38224 KB |
Output is correct |
39 |
Correct |
117 ms |
37712 KB |
Output is correct |
40 |
Correct |
121 ms |
37888 KB |
Output is correct |
41 |
Correct |
297 ms |
37956 KB |
Output is correct |
42 |
Correct |
368 ms |
37972 KB |
Output is correct |
43 |
Correct |
189 ms |
24920 KB |
Output is correct |
44 |
Correct |
290 ms |
38220 KB |
Output is correct |
45 |
Correct |
164 ms |
38164 KB |
Output is correct |
46 |
Correct |
117 ms |
37972 KB |
Output is correct |
47 |
Correct |
95 ms |
37144 KB |
Output is correct |
48 |
Correct |
89 ms |
36920 KB |
Output is correct |
49 |
Correct |
112 ms |
37368 KB |
Output is correct |
50 |
Correct |
238 ms |
37972 KB |
Output is correct |
51 |
Correct |
103 ms |
37408 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5028 ms |
101180 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5021 ms |
117116 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
3 ms |
14940 KB |
Output is correct |
3 |
Correct |
4 ms |
14940 KB |
Output is correct |
4 |
Correct |
4 ms |
14940 KB |
Output is correct |
5 |
Correct |
4 ms |
14940 KB |
Output is correct |
6 |
Correct |
4 ms |
14940 KB |
Output is correct |
7 |
Correct |
4 ms |
15196 KB |
Output is correct |
8 |
Correct |
4 ms |
14940 KB |
Output is correct |
9 |
Correct |
5 ms |
15196 KB |
Output is correct |
10 |
Correct |
4 ms |
14940 KB |
Output is correct |
11 |
Correct |
4 ms |
14940 KB |
Output is correct |
12 |
Correct |
4 ms |
15016 KB |
Output is correct |
13 |
Correct |
4 ms |
15012 KB |
Output is correct |
14 |
Correct |
4 ms |
14940 KB |
Output is correct |
15 |
Correct |
4 ms |
14940 KB |
Output is correct |
16 |
Correct |
4 ms |
15196 KB |
Output is correct |
17 |
Correct |
4 ms |
15016 KB |
Output is correct |
18 |
Correct |
6 ms |
15196 KB |
Output is correct |
19 |
Correct |
6 ms |
15196 KB |
Output is correct |
20 |
Correct |
4 ms |
14940 KB |
Output is correct |
21 |
Correct |
4 ms |
14940 KB |
Output is correct |
22 |
Correct |
5 ms |
15196 KB |
Output is correct |
23 |
Correct |
4 ms |
14940 KB |
Output is correct |
24 |
Correct |
4 ms |
14940 KB |
Output is correct |
25 |
Correct |
4 ms |
14940 KB |
Output is correct |
26 |
Correct |
4 ms |
15104 KB |
Output is correct |
27 |
Correct |
4 ms |
14936 KB |
Output is correct |
28 |
Correct |
3 ms |
14936 KB |
Output is correct |
29 |
Correct |
4 ms |
14940 KB |
Output is correct |
30 |
Correct |
4 ms |
14936 KB |
Output is correct |
31 |
Correct |
1666 ms |
41196 KB |
Output is correct |
32 |
Correct |
59 ms |
21992 KB |
Output is correct |
33 |
Correct |
247 ms |
38884 KB |
Output is correct |
34 |
Correct |
1314 ms |
38988 KB |
Output is correct |
35 |
Correct |
761 ms |
40784 KB |
Output is correct |
36 |
Correct |
258 ms |
40528 KB |
Output is correct |
37 |
Correct |
182 ms |
38224 KB |
Output is correct |
38 |
Correct |
158 ms |
38224 KB |
Output is correct |
39 |
Correct |
117 ms |
37712 KB |
Output is correct |
40 |
Correct |
121 ms |
37888 KB |
Output is correct |
41 |
Correct |
297 ms |
37956 KB |
Output is correct |
42 |
Correct |
368 ms |
37972 KB |
Output is correct |
43 |
Correct |
189 ms |
24920 KB |
Output is correct |
44 |
Correct |
290 ms |
38220 KB |
Output is correct |
45 |
Correct |
164 ms |
38164 KB |
Output is correct |
46 |
Correct |
117 ms |
37972 KB |
Output is correct |
47 |
Correct |
95 ms |
37144 KB |
Output is correct |
48 |
Correct |
89 ms |
36920 KB |
Output is correct |
49 |
Correct |
112 ms |
37368 KB |
Output is correct |
50 |
Correct |
238 ms |
37972 KB |
Output is correct |
51 |
Correct |
103 ms |
37408 KB |
Output is correct |
52 |
Execution timed out |
5013 ms |
44712 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
3 ms |
14940 KB |
Output is correct |
3 |
Correct |
4 ms |
14940 KB |
Output is correct |
4 |
Correct |
4 ms |
14940 KB |
Output is correct |
5 |
Correct |
4 ms |
14940 KB |
Output is correct |
6 |
Correct |
4 ms |
14940 KB |
Output is correct |
7 |
Correct |
4 ms |
15196 KB |
Output is correct |
8 |
Correct |
4 ms |
14940 KB |
Output is correct |
9 |
Correct |
5 ms |
15196 KB |
Output is correct |
10 |
Correct |
4 ms |
14940 KB |
Output is correct |
11 |
Correct |
4 ms |
14940 KB |
Output is correct |
12 |
Correct |
4 ms |
15016 KB |
Output is correct |
13 |
Correct |
4 ms |
15012 KB |
Output is correct |
14 |
Correct |
4 ms |
14940 KB |
Output is correct |
15 |
Correct |
4 ms |
14940 KB |
Output is correct |
16 |
Correct |
4 ms |
15196 KB |
Output is correct |
17 |
Correct |
4 ms |
15016 KB |
Output is correct |
18 |
Correct |
6 ms |
15196 KB |
Output is correct |
19 |
Correct |
6 ms |
15196 KB |
Output is correct |
20 |
Correct |
4 ms |
14940 KB |
Output is correct |
21 |
Correct |
4 ms |
14940 KB |
Output is correct |
22 |
Correct |
5 ms |
15196 KB |
Output is correct |
23 |
Correct |
4 ms |
14940 KB |
Output is correct |
24 |
Correct |
4 ms |
14940 KB |
Output is correct |
25 |
Correct |
4 ms |
14940 KB |
Output is correct |
26 |
Correct |
4 ms |
15104 KB |
Output is correct |
27 |
Correct |
4 ms |
14936 KB |
Output is correct |
28 |
Correct |
3 ms |
14936 KB |
Output is correct |
29 |
Correct |
4 ms |
14940 KB |
Output is correct |
30 |
Correct |
4 ms |
14936 KB |
Output is correct |
31 |
Correct |
1666 ms |
41196 KB |
Output is correct |
32 |
Correct |
59 ms |
21992 KB |
Output is correct |
33 |
Correct |
247 ms |
38884 KB |
Output is correct |
34 |
Correct |
1314 ms |
38988 KB |
Output is correct |
35 |
Correct |
761 ms |
40784 KB |
Output is correct |
36 |
Correct |
258 ms |
40528 KB |
Output is correct |
37 |
Correct |
182 ms |
38224 KB |
Output is correct |
38 |
Correct |
158 ms |
38224 KB |
Output is correct |
39 |
Correct |
117 ms |
37712 KB |
Output is correct |
40 |
Correct |
121 ms |
37888 KB |
Output is correct |
41 |
Correct |
297 ms |
37956 KB |
Output is correct |
42 |
Correct |
368 ms |
37972 KB |
Output is correct |
43 |
Correct |
189 ms |
24920 KB |
Output is correct |
44 |
Correct |
290 ms |
38220 KB |
Output is correct |
45 |
Correct |
164 ms |
38164 KB |
Output is correct |
46 |
Correct |
117 ms |
37972 KB |
Output is correct |
47 |
Correct |
95 ms |
37144 KB |
Output is correct |
48 |
Correct |
89 ms |
36920 KB |
Output is correct |
49 |
Correct |
112 ms |
37368 KB |
Output is correct |
50 |
Correct |
238 ms |
37972 KB |
Output is correct |
51 |
Correct |
103 ms |
37408 KB |
Output is correct |
52 |
Execution timed out |
5028 ms |
101180 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |