#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 = min(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 |
Incorrect |
2 ms |
472 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
472 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5090 ms |
8712 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5059 ms |
8932 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
472 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Incorrect |
2 ms |
472 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |