#include <bits/stdc++.h>
#define F first
#define S second
#define sz(x) int(x.size())
#define pb push_back
#define N 100005
#define M ll(998244353)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
vector <pair <pair <int, int>, int> > sost;
set <int> se[410];
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n, k, q;
cin >> n >> k >> q;
for (int i = 0; i < n; i++)
{
int x, t, l, r;
cin >> x >> t >> l >> r;
sost.pb({{l, x}, t});
sost.pb({{r, x}, -t});
}
vector <pair <pair <int, int>, int> > gr; gr.resize(q);
for (int i = 0; i < q; i++) {cin >> gr[i].F.S >> gr[i].F.F; gr[i].S = i;}
sort(sost.begin(), sost.end());
sort(gr.begin(), gr.end());
int ans[q];
int j = 0;
for (auto it : gr)
{
int nm = it.S, x = it.F.S, tr = it.F.F;
while (j < n + n && sost[j].F.F <= tr)
{
int tp = abs(sost[j].S);
if (sost[j].S > 0) se[tp].insert(sost[j].F.S);
else se[tp].erase(sost[j].F.S);
j++;
}
bool f = 1;
int mx = 0;
for (int i = 1; i <= k; i++)
{
if (sz(se[i]) == 0) {f = 0; break;}
auto it = se[i].upper_bound(x);
int mn = 1e9;
if (it != se[i].end()) mn = min(mn, abs(*it - x));
if (it != se[i].begin()) {it--; mn = min(mn, abs(*it - x)); }
mx = max(mx, mn);
}
if (!f) ans[nm] = -1; else ans[nm] = mx;
}
for (int i = 0; i < q; i++) cout << ans[i] << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
332 ms |
21936 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
324 ms |
22092 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
384 KB |
Output is correct |
2 |
Correct |
4 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Incorrect |
6 ms |
384 KB |
Output isn't correct |
6 |
Halted |
0 ms |
0 KB |
- |