#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a; i<int(b); i++)
int main() {
int n,q,k;
cin >> n >> k >> q;
vector<vector<int> > stores(n);
rep (i,0,n) {
int x,t,a,b;
cin >> x >> t >> a >> b;
stores[i]={x,t,a,b};
}
vector< pair<int,int> > queries(q);
rep (i,0,q) {
int l,y;
cin >> l >> y;
queries[i]=make_pair(l,y);
}
vector <set < vector<int> > > types(k);
rep (i,0,n) {
int t=stores[i][1]-1;
types[t].insert(stores[i]);
}
rep (i,0,q) {
int dist=0;
int l,y;
l=queries[i].first;
y=queries[i].second;
rep (i,0,k) {
int mindist=1e9;
for (auto a:types[i]) {
if (a[2]<=y && a[3]>=y)
mindist=min(mindist,abs(a[0]-l));
}
dist=max(dist,mindist);
}
if (dist==1e9) cout << -1 << endl;
else cout << dist << endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
436 KB |
Output is correct |
4 |
Correct |
2 ms |
436 KB |
Output is correct |
5 |
Correct |
13 ms |
468 KB |
Output is correct |
6 |
Correct |
14 ms |
516 KB |
Output is correct |
7 |
Correct |
12 ms |
516 KB |
Output is correct |
8 |
Correct |
15 ms |
648 KB |
Output is correct |
9 |
Correct |
14 ms |
648 KB |
Output is correct |
10 |
Correct |
21 ms |
648 KB |
Output is correct |
11 |
Correct |
16 ms |
648 KB |
Output is correct |
12 |
Correct |
14 ms |
648 KB |
Output is correct |
13 |
Correct |
20 ms |
648 KB |
Output is correct |
14 |
Correct |
13 ms |
648 KB |
Output is correct |
15 |
Correct |
13 ms |
648 KB |
Output is correct |
16 |
Correct |
17 ms |
648 KB |
Output is correct |
17 |
Correct |
17 ms |
648 KB |
Output is correct |
18 |
Correct |
16 ms |
648 KB |
Output is correct |
19 |
Correct |
16 ms |
748 KB |
Output is correct |
20 |
Correct |
16 ms |
748 KB |
Output is correct |
21 |
Correct |
15 ms |
748 KB |
Output is correct |
22 |
Correct |
15 ms |
748 KB |
Output is correct |
23 |
Correct |
14 ms |
748 KB |
Output is correct |
24 |
Correct |
14 ms |
748 KB |
Output is correct |
25 |
Correct |
15 ms |
748 KB |
Output is correct |
26 |
Correct |
14 ms |
748 KB |
Output is correct |
27 |
Correct |
16 ms |
748 KB |
Output is correct |
28 |
Correct |
13 ms |
748 KB |
Output is correct |
29 |
Correct |
19 ms |
748 KB |
Output is correct |
30 |
Correct |
11 ms |
748 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
436 KB |
Output is correct |
4 |
Correct |
2 ms |
436 KB |
Output is correct |
5 |
Correct |
13 ms |
468 KB |
Output is correct |
6 |
Correct |
14 ms |
516 KB |
Output is correct |
7 |
Correct |
12 ms |
516 KB |
Output is correct |
8 |
Correct |
15 ms |
648 KB |
Output is correct |
9 |
Correct |
14 ms |
648 KB |
Output is correct |
10 |
Correct |
21 ms |
648 KB |
Output is correct |
11 |
Correct |
16 ms |
648 KB |
Output is correct |
12 |
Correct |
14 ms |
648 KB |
Output is correct |
13 |
Correct |
20 ms |
648 KB |
Output is correct |
14 |
Correct |
13 ms |
648 KB |
Output is correct |
15 |
Correct |
13 ms |
648 KB |
Output is correct |
16 |
Correct |
17 ms |
648 KB |
Output is correct |
17 |
Correct |
17 ms |
648 KB |
Output is correct |
18 |
Correct |
16 ms |
648 KB |
Output is correct |
19 |
Correct |
16 ms |
748 KB |
Output is correct |
20 |
Correct |
16 ms |
748 KB |
Output is correct |
21 |
Correct |
15 ms |
748 KB |
Output is correct |
22 |
Correct |
15 ms |
748 KB |
Output is correct |
23 |
Correct |
14 ms |
748 KB |
Output is correct |
24 |
Correct |
14 ms |
748 KB |
Output is correct |
25 |
Correct |
15 ms |
748 KB |
Output is correct |
26 |
Correct |
14 ms |
748 KB |
Output is correct |
27 |
Correct |
16 ms |
748 KB |
Output is correct |
28 |
Correct |
13 ms |
748 KB |
Output is correct |
29 |
Correct |
19 ms |
748 KB |
Output is correct |
30 |
Correct |
11 ms |
748 KB |
Output is correct |
31 |
Execution timed out |
5041 ms |
10796 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5086 ms |
56324 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5027 ms |
59260 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
436 KB |
Output is correct |
4 |
Correct |
2 ms |
436 KB |
Output is correct |
5 |
Correct |
13 ms |
468 KB |
Output is correct |
6 |
Correct |
14 ms |
516 KB |
Output is correct |
7 |
Correct |
12 ms |
516 KB |
Output is correct |
8 |
Correct |
15 ms |
648 KB |
Output is correct |
9 |
Correct |
14 ms |
648 KB |
Output is correct |
10 |
Correct |
21 ms |
648 KB |
Output is correct |
11 |
Correct |
16 ms |
648 KB |
Output is correct |
12 |
Correct |
14 ms |
648 KB |
Output is correct |
13 |
Correct |
20 ms |
648 KB |
Output is correct |
14 |
Correct |
13 ms |
648 KB |
Output is correct |
15 |
Correct |
13 ms |
648 KB |
Output is correct |
16 |
Correct |
17 ms |
648 KB |
Output is correct |
17 |
Correct |
17 ms |
648 KB |
Output is correct |
18 |
Correct |
16 ms |
648 KB |
Output is correct |
19 |
Correct |
16 ms |
748 KB |
Output is correct |
20 |
Correct |
16 ms |
748 KB |
Output is correct |
21 |
Correct |
15 ms |
748 KB |
Output is correct |
22 |
Correct |
15 ms |
748 KB |
Output is correct |
23 |
Correct |
14 ms |
748 KB |
Output is correct |
24 |
Correct |
14 ms |
748 KB |
Output is correct |
25 |
Correct |
15 ms |
748 KB |
Output is correct |
26 |
Correct |
14 ms |
748 KB |
Output is correct |
27 |
Correct |
16 ms |
748 KB |
Output is correct |
28 |
Correct |
13 ms |
748 KB |
Output is correct |
29 |
Correct |
19 ms |
748 KB |
Output is correct |
30 |
Correct |
11 ms |
748 KB |
Output is correct |
31 |
Execution timed out |
5041 ms |
10796 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
248 KB |
Output is correct |
2 |
Correct |
2 ms |
356 KB |
Output is correct |
3 |
Correct |
3 ms |
436 KB |
Output is correct |
4 |
Correct |
2 ms |
436 KB |
Output is correct |
5 |
Correct |
13 ms |
468 KB |
Output is correct |
6 |
Correct |
14 ms |
516 KB |
Output is correct |
7 |
Correct |
12 ms |
516 KB |
Output is correct |
8 |
Correct |
15 ms |
648 KB |
Output is correct |
9 |
Correct |
14 ms |
648 KB |
Output is correct |
10 |
Correct |
21 ms |
648 KB |
Output is correct |
11 |
Correct |
16 ms |
648 KB |
Output is correct |
12 |
Correct |
14 ms |
648 KB |
Output is correct |
13 |
Correct |
20 ms |
648 KB |
Output is correct |
14 |
Correct |
13 ms |
648 KB |
Output is correct |
15 |
Correct |
13 ms |
648 KB |
Output is correct |
16 |
Correct |
17 ms |
648 KB |
Output is correct |
17 |
Correct |
17 ms |
648 KB |
Output is correct |
18 |
Correct |
16 ms |
648 KB |
Output is correct |
19 |
Correct |
16 ms |
748 KB |
Output is correct |
20 |
Correct |
16 ms |
748 KB |
Output is correct |
21 |
Correct |
15 ms |
748 KB |
Output is correct |
22 |
Correct |
15 ms |
748 KB |
Output is correct |
23 |
Correct |
14 ms |
748 KB |
Output is correct |
24 |
Correct |
14 ms |
748 KB |
Output is correct |
25 |
Correct |
15 ms |
748 KB |
Output is correct |
26 |
Correct |
14 ms |
748 KB |
Output is correct |
27 |
Correct |
16 ms |
748 KB |
Output is correct |
28 |
Correct |
13 ms |
748 KB |
Output is correct |
29 |
Correct |
19 ms |
748 KB |
Output is correct |
30 |
Correct |
11 ms |
748 KB |
Output is correct |
31 |
Execution timed out |
5041 ms |
10796 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |