#include <bits/stdc++.h>
#define F first
#define S second
#define sz(x) ll(x.size())
#define N 100005
#define M ll(998244353)
using namespace std;
typedef long double ld;
typedef long long ll;
typedef short int si;
int main()
{
ios_base::sync_with_stdio(0); istream::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n, q, k;
cin >> n >> k >> q;
vector <pair <pair <pair <ll, ll>, ll>, ll> > g; g.resize(n);
for (ll i = 0; i < n; i++) cin >> g[i].F.F.F >> g[i].F.F.S >> g[i].F.S >> g[i].S;
for (;q > 0; q--)
{
ll x, y;
cin >> x >> y;
ll mk[k + 1];
for (ll i = 0; i <= k; i++) mk[i] = 0;
ll mx = 0, kol = 0;
for (ll i = 0; i < n; i++)
if (g[i].F.S <= y && y <= g[i].S)
{
if (g[i].F.S <= y && y <= g[i].S && !mk[g[i].F.F.S]) {mk[g[i].F.F.S] = 1; kol++;}
mx = max(mx, abs(x - g[i].F.F.F));
}
if (kol < k) {cout << -1 << endl; continue;}
cout << mx << endl;
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5079 ms |
10528 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5048 ms |
9860 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
384 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
5 ms |
384 KB |
Output is correct |
4 |
Incorrect |
4 ms |
384 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |