#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
struct store {
int x, t, a, b;
store(int x, int t, int a, int b) : x(x), t(t), a(a), b(b) {}
};
int main() {
ios_base::sync_with_stdio(false); cin.tie(0); cout.setf(ios::fixed); cout.precision(20);
#ifdef LOCAL
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
int n, k, q;
cin >> n >> k >> q;
vector <store> kek;
for (int i = 0; i < n; ++i) {
int x, t, a, b;
cin >> x >> t >> a >> b;
--t;
kek.emplace_back(x, t, a, b);
}
while (q--) {
int l, y;
cin >> l >> y;
vector <int> mx(k, (int)1e9);
for (auto s : kek) {
if (s.a <= y && y <= s.b) {
mx[s.t] = min(mx[s.t], abs(l - s.x));
}
}
int ans = -1e9;
for (int i = 0; i < k; ++i) {
ans = max(ans, mx[i]);
}
if (ans > 5e8) {
cout << "-1\n";
}
else {
cout << ans << '\n';
}
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
580 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
4 ms |
632 KB |
Output is correct |
7 |
Correct |
4 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
632 KB |
Output is correct |
9 |
Correct |
3 ms |
652 KB |
Output is correct |
10 |
Correct |
3 ms |
700 KB |
Output is correct |
11 |
Correct |
3 ms |
720 KB |
Output is correct |
12 |
Correct |
3 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
808 KB |
Output is correct |
14 |
Correct |
3 ms |
828 KB |
Output is correct |
15 |
Correct |
4 ms |
856 KB |
Output is correct |
16 |
Correct |
4 ms |
872 KB |
Output is correct |
17 |
Correct |
3 ms |
896 KB |
Output is correct |
18 |
Correct |
3 ms |
912 KB |
Output is correct |
19 |
Correct |
4 ms |
996 KB |
Output is correct |
20 |
Correct |
3 ms |
1140 KB |
Output is correct |
21 |
Correct |
4 ms |
1140 KB |
Output is correct |
22 |
Correct |
3 ms |
1140 KB |
Output is correct |
23 |
Correct |
3 ms |
1140 KB |
Output is correct |
24 |
Correct |
3 ms |
1228 KB |
Output is correct |
25 |
Correct |
3 ms |
1228 KB |
Output is correct |
26 |
Correct |
3 ms |
1228 KB |
Output is correct |
27 |
Correct |
3 ms |
1228 KB |
Output is correct |
28 |
Correct |
3 ms |
1232 KB |
Output is correct |
29 |
Correct |
3 ms |
1252 KB |
Output is correct |
30 |
Correct |
2 ms |
1272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
580 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
4 ms |
632 KB |
Output is correct |
7 |
Correct |
4 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
632 KB |
Output is correct |
9 |
Correct |
3 ms |
652 KB |
Output is correct |
10 |
Correct |
3 ms |
700 KB |
Output is correct |
11 |
Correct |
3 ms |
720 KB |
Output is correct |
12 |
Correct |
3 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
808 KB |
Output is correct |
14 |
Correct |
3 ms |
828 KB |
Output is correct |
15 |
Correct |
4 ms |
856 KB |
Output is correct |
16 |
Correct |
4 ms |
872 KB |
Output is correct |
17 |
Correct |
3 ms |
896 KB |
Output is correct |
18 |
Correct |
3 ms |
912 KB |
Output is correct |
19 |
Correct |
4 ms |
996 KB |
Output is correct |
20 |
Correct |
3 ms |
1140 KB |
Output is correct |
21 |
Correct |
4 ms |
1140 KB |
Output is correct |
22 |
Correct |
3 ms |
1140 KB |
Output is correct |
23 |
Correct |
3 ms |
1140 KB |
Output is correct |
24 |
Correct |
3 ms |
1228 KB |
Output is correct |
25 |
Correct |
3 ms |
1228 KB |
Output is correct |
26 |
Correct |
3 ms |
1228 KB |
Output is correct |
27 |
Correct |
3 ms |
1228 KB |
Output is correct |
28 |
Correct |
3 ms |
1232 KB |
Output is correct |
29 |
Correct |
3 ms |
1252 KB |
Output is correct |
30 |
Correct |
2 ms |
1272 KB |
Output is correct |
31 |
Execution timed out |
5077 ms |
5184 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5060 ms |
12004 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5087 ms |
12008 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
580 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
4 ms |
632 KB |
Output is correct |
7 |
Correct |
4 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
632 KB |
Output is correct |
9 |
Correct |
3 ms |
652 KB |
Output is correct |
10 |
Correct |
3 ms |
700 KB |
Output is correct |
11 |
Correct |
3 ms |
720 KB |
Output is correct |
12 |
Correct |
3 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
808 KB |
Output is correct |
14 |
Correct |
3 ms |
828 KB |
Output is correct |
15 |
Correct |
4 ms |
856 KB |
Output is correct |
16 |
Correct |
4 ms |
872 KB |
Output is correct |
17 |
Correct |
3 ms |
896 KB |
Output is correct |
18 |
Correct |
3 ms |
912 KB |
Output is correct |
19 |
Correct |
4 ms |
996 KB |
Output is correct |
20 |
Correct |
3 ms |
1140 KB |
Output is correct |
21 |
Correct |
4 ms |
1140 KB |
Output is correct |
22 |
Correct |
3 ms |
1140 KB |
Output is correct |
23 |
Correct |
3 ms |
1140 KB |
Output is correct |
24 |
Correct |
3 ms |
1228 KB |
Output is correct |
25 |
Correct |
3 ms |
1228 KB |
Output is correct |
26 |
Correct |
3 ms |
1228 KB |
Output is correct |
27 |
Correct |
3 ms |
1228 KB |
Output is correct |
28 |
Correct |
3 ms |
1232 KB |
Output is correct |
29 |
Correct |
3 ms |
1252 KB |
Output is correct |
30 |
Correct |
2 ms |
1272 KB |
Output is correct |
31 |
Execution timed out |
5077 ms |
5184 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
504 KB |
Output is correct |
3 |
Correct |
2 ms |
580 KB |
Output is correct |
4 |
Correct |
2 ms |
632 KB |
Output is correct |
5 |
Correct |
3 ms |
632 KB |
Output is correct |
6 |
Correct |
4 ms |
632 KB |
Output is correct |
7 |
Correct |
4 ms |
632 KB |
Output is correct |
8 |
Correct |
3 ms |
632 KB |
Output is correct |
9 |
Correct |
3 ms |
652 KB |
Output is correct |
10 |
Correct |
3 ms |
700 KB |
Output is correct |
11 |
Correct |
3 ms |
720 KB |
Output is correct |
12 |
Correct |
3 ms |
756 KB |
Output is correct |
13 |
Correct |
3 ms |
808 KB |
Output is correct |
14 |
Correct |
3 ms |
828 KB |
Output is correct |
15 |
Correct |
4 ms |
856 KB |
Output is correct |
16 |
Correct |
4 ms |
872 KB |
Output is correct |
17 |
Correct |
3 ms |
896 KB |
Output is correct |
18 |
Correct |
3 ms |
912 KB |
Output is correct |
19 |
Correct |
4 ms |
996 KB |
Output is correct |
20 |
Correct |
3 ms |
1140 KB |
Output is correct |
21 |
Correct |
4 ms |
1140 KB |
Output is correct |
22 |
Correct |
3 ms |
1140 KB |
Output is correct |
23 |
Correct |
3 ms |
1140 KB |
Output is correct |
24 |
Correct |
3 ms |
1228 KB |
Output is correct |
25 |
Correct |
3 ms |
1228 KB |
Output is correct |
26 |
Correct |
3 ms |
1228 KB |
Output is correct |
27 |
Correct |
3 ms |
1228 KB |
Output is correct |
28 |
Correct |
3 ms |
1232 KB |
Output is correct |
29 |
Correct |
3 ms |
1252 KB |
Output is correct |
30 |
Correct |
2 ms |
1272 KB |
Output is correct |
31 |
Execution timed out |
5077 ms |
5184 KB |
Time limit exceeded |
32 |
Halted |
0 ms |
0 KB |
- |