#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, k, q, i, l, y, cur, ans, x[300001], t[300001], a[300001], b[300001];
vector<pair<int, pair<int, int>>> g[300001];
signed main() {
cin.tie(0)->sync_with_stdio(0);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
#endif
cin >> n >> k >> q;
for (i = 1; i <= n; i++) {
cin >> x[i] >> t[i] >> a[i] >> b[i];
g[t[i]].push_back({x[i], {a[i], b[i]}});
}
while (q--) {
cin >> l >> y;
ans = 0;
for (i = 1; i <= k; i++) {
cur = 1e18;
for (auto j : g[i]) {
if (j.second.first <= y && y <= j.second.second) {
cur = min(cur, abs(l - j.first));
}
}
if (cur >= 1e17) {
ans = -1;
break;
}
ans = max(ans, cur);
}
cout << ans << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
3 ms |
14996 KB |
Output is correct |
3 |
Correct |
4 ms |
14936 KB |
Output is correct |
4 |
Correct |
3 ms |
15000 KB |
Output is correct |
5 |
Correct |
3 ms |
15004 KB |
Output is correct |
6 |
Correct |
3 ms |
14940 KB |
Output is correct |
7 |
Correct |
3 ms |
14936 KB |
Output is correct |
8 |
Correct |
3 ms |
14940 KB |
Output is correct |
9 |
Correct |
3 ms |
14940 KB |
Output is correct |
10 |
Correct |
3 ms |
14940 KB |
Output is correct |
11 |
Correct |
3 ms |
14964 KB |
Output is correct |
12 |
Correct |
3 ms |
14940 KB |
Output is correct |
13 |
Correct |
3 ms |
14936 KB |
Output is correct |
14 |
Correct |
3 ms |
14940 KB |
Output is correct |
15 |
Correct |
4 ms |
15048 KB |
Output is correct |
16 |
Correct |
3 ms |
14940 KB |
Output is correct |
17 |
Correct |
4 ms |
14940 KB |
Output is correct |
18 |
Correct |
4 ms |
14940 KB |
Output is correct |
19 |
Correct |
3 ms |
14940 KB |
Output is correct |
20 |
Correct |
3 ms |
14940 KB |
Output is correct |
21 |
Correct |
3 ms |
14940 KB |
Output is correct |
22 |
Correct |
3 ms |
14940 KB |
Output is correct |
23 |
Correct |
3 ms |
14940 KB |
Output is correct |
24 |
Correct |
3 ms |
14940 KB |
Output is correct |
25 |
Correct |
4 ms |
14940 KB |
Output is correct |
26 |
Correct |
3 ms |
14936 KB |
Output is correct |
27 |
Correct |
3 ms |
14940 KB |
Output is correct |
28 |
Correct |
3 ms |
14968 KB |
Output is correct |
29 |
Correct |
3 ms |
14940 KB |
Output is correct |
30 |
Correct |
3 ms |
14940 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
3 ms |
14996 KB |
Output is correct |
3 |
Correct |
4 ms |
14936 KB |
Output is correct |
4 |
Correct |
3 ms |
15000 KB |
Output is correct |
5 |
Correct |
3 ms |
15004 KB |
Output is correct |
6 |
Correct |
3 ms |
14940 KB |
Output is correct |
7 |
Correct |
3 ms |
14936 KB |
Output is correct |
8 |
Correct |
3 ms |
14940 KB |
Output is correct |
9 |
Correct |
3 ms |
14940 KB |
Output is correct |
10 |
Correct |
3 ms |
14940 KB |
Output is correct |
11 |
Correct |
3 ms |
14964 KB |
Output is correct |
12 |
Correct |
3 ms |
14940 KB |
Output is correct |
13 |
Correct |
3 ms |
14936 KB |
Output is correct |
14 |
Correct |
3 ms |
14940 KB |
Output is correct |
15 |
Correct |
4 ms |
15048 KB |
Output is correct |
16 |
Correct |
3 ms |
14940 KB |
Output is correct |
17 |
Correct |
4 ms |
14940 KB |
Output is correct |
18 |
Correct |
4 ms |
14940 KB |
Output is correct |
19 |
Correct |
3 ms |
14940 KB |
Output is correct |
20 |
Correct |
3 ms |
14940 KB |
Output is correct |
21 |
Correct |
3 ms |
14940 KB |
Output is correct |
22 |
Correct |
3 ms |
14940 KB |
Output is correct |
23 |
Correct |
3 ms |
14940 KB |
Output is correct |
24 |
Correct |
3 ms |
14940 KB |
Output is correct |
25 |
Correct |
4 ms |
14940 KB |
Output is correct |
26 |
Correct |
3 ms |
14936 KB |
Output is correct |
27 |
Correct |
3 ms |
14940 KB |
Output is correct |
28 |
Correct |
3 ms |
14968 KB |
Output is correct |
29 |
Correct |
3 ms |
14940 KB |
Output is correct |
30 |
Correct |
3 ms |
14940 KB |
Output is correct |
31 |
Execution timed out |
5061 ms |
20336 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5101 ms |
36356 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5046 ms |
35184 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 |
14996 KB |
Output is correct |
3 |
Correct |
4 ms |
14936 KB |
Output is correct |
4 |
Correct |
3 ms |
15000 KB |
Output is correct |
5 |
Correct |
3 ms |
15004 KB |
Output is correct |
6 |
Correct |
3 ms |
14940 KB |
Output is correct |
7 |
Correct |
3 ms |
14936 KB |
Output is correct |
8 |
Correct |
3 ms |
14940 KB |
Output is correct |
9 |
Correct |
3 ms |
14940 KB |
Output is correct |
10 |
Correct |
3 ms |
14940 KB |
Output is correct |
11 |
Correct |
3 ms |
14964 KB |
Output is correct |
12 |
Correct |
3 ms |
14940 KB |
Output is correct |
13 |
Correct |
3 ms |
14936 KB |
Output is correct |
14 |
Correct |
3 ms |
14940 KB |
Output is correct |
15 |
Correct |
4 ms |
15048 KB |
Output is correct |
16 |
Correct |
3 ms |
14940 KB |
Output is correct |
17 |
Correct |
4 ms |
14940 KB |
Output is correct |
18 |
Correct |
4 ms |
14940 KB |
Output is correct |
19 |
Correct |
3 ms |
14940 KB |
Output is correct |
20 |
Correct |
3 ms |
14940 KB |
Output is correct |
21 |
Correct |
3 ms |
14940 KB |
Output is correct |
22 |
Correct |
3 ms |
14940 KB |
Output is correct |
23 |
Correct |
3 ms |
14940 KB |
Output is correct |
24 |
Correct |
3 ms |
14940 KB |
Output is correct |
25 |
Correct |
4 ms |
14940 KB |
Output is correct |
26 |
Correct |
3 ms |
14936 KB |
Output is correct |
27 |
Correct |
3 ms |
14940 KB |
Output is correct |
28 |
Correct |
3 ms |
14968 KB |
Output is correct |
29 |
Correct |
3 ms |
14940 KB |
Output is correct |
30 |
Correct |
3 ms |
14940 KB |
Output is correct |
31 |
Execution timed out |
5061 ms |
20336 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
14940 KB |
Output is correct |
2 |
Correct |
3 ms |
14996 KB |
Output is correct |
3 |
Correct |
4 ms |
14936 KB |
Output is correct |
4 |
Correct |
3 ms |
15000 KB |
Output is correct |
5 |
Correct |
3 ms |
15004 KB |
Output is correct |
6 |
Correct |
3 ms |
14940 KB |
Output is correct |
7 |
Correct |
3 ms |
14936 KB |
Output is correct |
8 |
Correct |
3 ms |
14940 KB |
Output is correct |
9 |
Correct |
3 ms |
14940 KB |
Output is correct |
10 |
Correct |
3 ms |
14940 KB |
Output is correct |
11 |
Correct |
3 ms |
14964 KB |
Output is correct |
12 |
Correct |
3 ms |
14940 KB |
Output is correct |
13 |
Correct |
3 ms |
14936 KB |
Output is correct |
14 |
Correct |
3 ms |
14940 KB |
Output is correct |
15 |
Correct |
4 ms |
15048 KB |
Output is correct |
16 |
Correct |
3 ms |
14940 KB |
Output is correct |
17 |
Correct |
4 ms |
14940 KB |
Output is correct |
18 |
Correct |
4 ms |
14940 KB |
Output is correct |
19 |
Correct |
3 ms |
14940 KB |
Output is correct |
20 |
Correct |
3 ms |
14940 KB |
Output is correct |
21 |
Correct |
3 ms |
14940 KB |
Output is correct |
22 |
Correct |
3 ms |
14940 KB |
Output is correct |
23 |
Correct |
3 ms |
14940 KB |
Output is correct |
24 |
Correct |
3 ms |
14940 KB |
Output is correct |
25 |
Correct |
4 ms |
14940 KB |
Output is correct |
26 |
Correct |
3 ms |
14936 KB |
Output is correct |
27 |
Correct |
3 ms |
14940 KB |
Output is correct |
28 |
Correct |
3 ms |
14968 KB |
Output is correct |
29 |
Correct |
3 ms |
14940 KB |
Output is correct |
30 |
Correct |
3 ms |
14940 KB |
Output is correct |
31 |
Execution timed out |
5061 ms |
20336 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |