#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ii pair<ll,ll>
#define iii tuple<ll,ll,ll>
#ifndef DEBUG
#define cerr if (0) cerr
#define endl '\n'
#endif // DEBUG
const ll maxn=2e5+5;
const ll inf=1e15;
const ll mod=1e9+7;
multiset<ll> s[405];
vector<tuple<ll,ll,ll,ll>> v;
vector<iii> q;
ll ans[maxn];
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n,qu,x,t,a,b,k;
cin>>n>>k>>qu;
for (int i=1;i<=n;i++){
cin>>x>>t>>a>>b;
v.emplace_back(a,x,t,1);
v.emplace_back(b+1,x,t,-1);
}
sort(v.begin(),v.end());
for (int i=1;i<=qu;i++){
cin>>x>>t;
q.emplace_back(t,x,i);
}
sort(q.begin(),q.end());
for (int i=1;i<=k;i++) s[i].emplace(-inf),s[i].emplace(inf);
ll ptr=0;
for (auto [t,x,idx]:q){
while (ptr!=v.size() && get<0>(v[ptr])<=t){
ll a,b,c,d;
tie(a,b,c,d)=v[ptr];
if (d==-1){
s[c].erase(s[c].find(b));
} else{
s[c].emplace(b);
}
ptr++;
}
ll tot=0;
for (int i=1;i<=k;i++){
auto it=s[i].lower_bound(x);
auto it2=it;
it2--;
ll dis=min(abs(x-*it),abs(x-*it2));
tot=max(dis,tot);
}
if (tot>mod) ans[idx]=-1;
else ans[idx]=tot;
}
for (int i=1;i<=qu;i++) cout<<ans[i]<<endl;
return 0;
}
Compilation message
new_home.cpp: In function 'int main()':
new_home.cpp:40:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::tuple<long long int, long long int, long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
40 | while (ptr!=v.size() && get<0>(v[ptr])<=t){
| ~~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
572 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
488 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
424 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
572 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
488 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
424 KB |
Output is correct |
31 |
Correct |
1526 ms |
12356 KB |
Output is correct |
32 |
Correct |
52 ms |
8644 KB |
Output is correct |
33 |
Correct |
120 ms |
10856 KB |
Output is correct |
34 |
Correct |
1199 ms |
10864 KB |
Output is correct |
35 |
Correct |
703 ms |
12108 KB |
Output is correct |
36 |
Correct |
140 ms |
12080 KB |
Output is correct |
37 |
Correct |
109 ms |
10860 KB |
Output is correct |
38 |
Correct |
80 ms |
10680 KB |
Output is correct |
39 |
Correct |
67 ms |
10792 KB |
Output is correct |
40 |
Correct |
57 ms |
10640 KB |
Output is correct |
41 |
Correct |
217 ms |
11052 KB |
Output is correct |
42 |
Correct |
290 ms |
10868 KB |
Output is correct |
43 |
Correct |
381 ms |
11720 KB |
Output is correct |
44 |
Correct |
183 ms |
10940 KB |
Output is correct |
45 |
Correct |
89 ms |
10912 KB |
Output is correct |
46 |
Correct |
50 ms |
10944 KB |
Output is correct |
47 |
Correct |
48 ms |
10692 KB |
Output is correct |
48 |
Correct |
46 ms |
10436 KB |
Output is correct |
49 |
Correct |
58 ms |
10696 KB |
Output is correct |
50 |
Correct |
177 ms |
10864 KB |
Output is correct |
51 |
Correct |
51 ms |
10692 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
258 ms |
94644 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
248 ms |
94460 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
572 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
488 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
424 KB |
Output is correct |
31 |
Correct |
1526 ms |
12356 KB |
Output is correct |
32 |
Correct |
52 ms |
8644 KB |
Output is correct |
33 |
Correct |
120 ms |
10856 KB |
Output is correct |
34 |
Correct |
1199 ms |
10864 KB |
Output is correct |
35 |
Correct |
703 ms |
12108 KB |
Output is correct |
36 |
Correct |
140 ms |
12080 KB |
Output is correct |
37 |
Correct |
109 ms |
10860 KB |
Output is correct |
38 |
Correct |
80 ms |
10680 KB |
Output is correct |
39 |
Correct |
67 ms |
10792 KB |
Output is correct |
40 |
Correct |
57 ms |
10640 KB |
Output is correct |
41 |
Correct |
217 ms |
11052 KB |
Output is correct |
42 |
Correct |
290 ms |
10868 KB |
Output is correct |
43 |
Correct |
381 ms |
11720 KB |
Output is correct |
44 |
Correct |
183 ms |
10940 KB |
Output is correct |
45 |
Correct |
89 ms |
10912 KB |
Output is correct |
46 |
Correct |
50 ms |
10944 KB |
Output is correct |
47 |
Correct |
48 ms |
10692 KB |
Output is correct |
48 |
Correct |
46 ms |
10436 KB |
Output is correct |
49 |
Correct |
58 ms |
10696 KB |
Output is correct |
50 |
Correct |
177 ms |
10864 KB |
Output is correct |
51 |
Correct |
51 ms |
10692 KB |
Output is correct |
52 |
Runtime error |
47 ms |
17344 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
348 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
344 KB |
Output is correct |
9 |
Correct |
2 ms |
856 KB |
Output is correct |
10 |
Correct |
1 ms |
600 KB |
Output is correct |
11 |
Correct |
1 ms |
344 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
348 KB |
Output is correct |
14 |
Correct |
1 ms |
348 KB |
Output is correct |
15 |
Correct |
1 ms |
344 KB |
Output is correct |
16 |
Correct |
1 ms |
348 KB |
Output is correct |
17 |
Correct |
1 ms |
348 KB |
Output is correct |
18 |
Correct |
1 ms |
572 KB |
Output is correct |
19 |
Correct |
1 ms |
348 KB |
Output is correct |
20 |
Correct |
1 ms |
348 KB |
Output is correct |
21 |
Correct |
2 ms |
604 KB |
Output is correct |
22 |
Correct |
2 ms |
604 KB |
Output is correct |
23 |
Correct |
1 ms |
348 KB |
Output is correct |
24 |
Correct |
1 ms |
348 KB |
Output is correct |
25 |
Correct |
1 ms |
348 KB |
Output is correct |
26 |
Correct |
1 ms |
344 KB |
Output is correct |
27 |
Correct |
1 ms |
488 KB |
Output is correct |
28 |
Correct |
1 ms |
348 KB |
Output is correct |
29 |
Correct |
1 ms |
348 KB |
Output is correct |
30 |
Correct |
1 ms |
424 KB |
Output is correct |
31 |
Correct |
1526 ms |
12356 KB |
Output is correct |
32 |
Correct |
52 ms |
8644 KB |
Output is correct |
33 |
Correct |
120 ms |
10856 KB |
Output is correct |
34 |
Correct |
1199 ms |
10864 KB |
Output is correct |
35 |
Correct |
703 ms |
12108 KB |
Output is correct |
36 |
Correct |
140 ms |
12080 KB |
Output is correct |
37 |
Correct |
109 ms |
10860 KB |
Output is correct |
38 |
Correct |
80 ms |
10680 KB |
Output is correct |
39 |
Correct |
67 ms |
10792 KB |
Output is correct |
40 |
Correct |
57 ms |
10640 KB |
Output is correct |
41 |
Correct |
217 ms |
11052 KB |
Output is correct |
42 |
Correct |
290 ms |
10868 KB |
Output is correct |
43 |
Correct |
381 ms |
11720 KB |
Output is correct |
44 |
Correct |
183 ms |
10940 KB |
Output is correct |
45 |
Correct |
89 ms |
10912 KB |
Output is correct |
46 |
Correct |
50 ms |
10944 KB |
Output is correct |
47 |
Correct |
48 ms |
10692 KB |
Output is correct |
48 |
Correct |
46 ms |
10436 KB |
Output is correct |
49 |
Correct |
58 ms |
10696 KB |
Output is correct |
50 |
Correct |
177 ms |
10864 KB |
Output is correct |
51 |
Correct |
51 ms |
10692 KB |
Output is correct |
52 |
Runtime error |
258 ms |
94644 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |