#include<bits/stdc++.h>
#define ll long long
#define F first
#define S second
#define in insert
#define pb push_back
#define ppb pop_back()
#define d3 ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define cans cout << ans << "\n";
#define yes cout << "Yes" << "\n";
#define no cout << "No" << "\n";
#define pll pair<ll,ll>
#define lin cout << "\n";
#define sqr 340
#define mod 1000000007
#define mid ((l+r)/2)
#define lc (2*n)
#define rc (2*n+1)
using namespace std;
ll fp(ll x , ll y)
{
if(y==0)
return 1;
ll z = fp(x,y/2);
if(y&1)
return z*z%mod*x%mod;
else
return z*z%mod;
}
int sqrot(ll x)
{
int l = 0 , r = INT_MAX;
while(l<=r)
{
if(mid*mid>=x)
r=mid-1;
else
l=mid+1;
}
return r+1;
}
ll cel(ll x , ll y)
{
return x/y + bool(x%y);
}
pair<pll,pll> a[60009];
pair<pll,ll> w[60009];
ll l[60009];
ll y[60009];
multiset<pll> s1[409] , s2[409];
ll Q[60009];
int main()
{
d3
ll n , k , q;
cin >> n >> k >> q;
for(int i = 0 ; n>i ; i++)
cin >> a[i].S.F >> a[i].S.S >> a[i].F.F >> a[i].F.S;
sort(a,a+n);
for(int i = 0 ; q>i ; i++)
{
cin >> w[i].F.S >> w[i].F.F;
w[i].S=i;
}
sort(w,w+q);
for(int i = 0 ; q>i ; i++)
{
l[i]=w[i].F.S;
y[i]=w[i].F.F;
}
ll idx = 0;
for(int i = 0 ; q>i ; i++)
{
ll t = y[i];
ll c = l[i];
for(;n>idx;idx++)
{
if(a[idx].F.F>t)
break;
s1[a[idx].S.S].in({a[idx].S.F,a[idx].F.S});
s2[a[idx].S.S].in({a[idx].F.S,a[idx].S.F});
}
ll ans = 0;
for(int j = 1 ; k>=j ; j++)
{
while(!s2[j].empty())
{
auto it = s2[j].begin();
if(it->F>=t)
break;
s1[j].erase(s1[j].find({it->S,it->F}));
s2[j].erase(it);
}
if(s1[j].empty())
ans=-1;
if(ans==-1)
continue;
auto it = s1[j].upper_bound({c,0});
ll ans1 = 1e10;
if(it!=s1[j].end())
ans1=min(ans1,it->F-c);
if(it!=s1[j].begin())
{
it--;
ans1=min(ans1,c-it->F);
}
ans=max(ans1,ans);
}
Q[w[i].S]=ans;
}
for(int i = 0 ; q>i ; i++)
cout << Q[i] << "\n";
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4696 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4836 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
1 ms |
4588 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
2 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
2 ms |
4444 KB |
Output is correct |
22 |
Correct |
2 ms |
4580 KB |
Output is correct |
23 |
Correct |
2 ms |
4444 KB |
Output is correct |
24 |
Correct |
2 ms |
4444 KB |
Output is correct |
25 |
Correct |
2 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4696 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4836 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
1 ms |
4588 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
2 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
2 ms |
4444 KB |
Output is correct |
22 |
Correct |
2 ms |
4580 KB |
Output is correct |
23 |
Correct |
2 ms |
4444 KB |
Output is correct |
24 |
Correct |
2 ms |
4444 KB |
Output is correct |
25 |
Correct |
2 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
1975 ms |
15920 KB |
Output is correct |
32 |
Correct |
57 ms |
9808 KB |
Output is correct |
33 |
Correct |
149 ms |
11088 KB |
Output is correct |
34 |
Correct |
1499 ms |
11152 KB |
Output is correct |
35 |
Correct |
903 ms |
15864 KB |
Output is correct |
36 |
Correct |
178 ms |
15908 KB |
Output is correct |
37 |
Correct |
136 ms |
9040 KB |
Output is correct |
38 |
Correct |
76 ms |
8824 KB |
Output is correct |
39 |
Correct |
63 ms |
8312 KB |
Output is correct |
40 |
Correct |
63 ms |
8252 KB |
Output is correct |
41 |
Correct |
216 ms |
8676 KB |
Output is correct |
42 |
Correct |
176 ms |
8536 KB |
Output is correct |
43 |
Correct |
483 ms |
15532 KB |
Output is correct |
44 |
Correct |
173 ms |
8528 KB |
Output is correct |
45 |
Correct |
83 ms |
8588 KB |
Output is correct |
46 |
Correct |
48 ms |
8548 KB |
Output is correct |
47 |
Correct |
45 ms |
8148 KB |
Output is correct |
48 |
Correct |
42 ms |
8016 KB |
Output is correct |
49 |
Correct |
53 ms |
8196 KB |
Output is correct |
50 |
Correct |
149 ms |
8548 KB |
Output is correct |
51 |
Correct |
47 ms |
8272 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
19 ms |
9820 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
24 ms |
9812 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4696 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4836 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
1 ms |
4588 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
2 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
2 ms |
4444 KB |
Output is correct |
22 |
Correct |
2 ms |
4580 KB |
Output is correct |
23 |
Correct |
2 ms |
4444 KB |
Output is correct |
24 |
Correct |
2 ms |
4444 KB |
Output is correct |
25 |
Correct |
2 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
1975 ms |
15920 KB |
Output is correct |
32 |
Correct |
57 ms |
9808 KB |
Output is correct |
33 |
Correct |
149 ms |
11088 KB |
Output is correct |
34 |
Correct |
1499 ms |
11152 KB |
Output is correct |
35 |
Correct |
903 ms |
15864 KB |
Output is correct |
36 |
Correct |
178 ms |
15908 KB |
Output is correct |
37 |
Correct |
136 ms |
9040 KB |
Output is correct |
38 |
Correct |
76 ms |
8824 KB |
Output is correct |
39 |
Correct |
63 ms |
8312 KB |
Output is correct |
40 |
Correct |
63 ms |
8252 KB |
Output is correct |
41 |
Correct |
216 ms |
8676 KB |
Output is correct |
42 |
Correct |
176 ms |
8536 KB |
Output is correct |
43 |
Correct |
483 ms |
15532 KB |
Output is correct |
44 |
Correct |
173 ms |
8528 KB |
Output is correct |
45 |
Correct |
83 ms |
8588 KB |
Output is correct |
46 |
Correct |
48 ms |
8548 KB |
Output is correct |
47 |
Correct |
45 ms |
8148 KB |
Output is correct |
48 |
Correct |
42 ms |
8016 KB |
Output is correct |
49 |
Correct |
53 ms |
8196 KB |
Output is correct |
50 |
Correct |
149 ms |
8548 KB |
Output is correct |
51 |
Correct |
47 ms |
8272 KB |
Output is correct |
52 |
Runtime error |
38 ms |
12760 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
4440 KB |
Output is correct |
2 |
Correct |
1 ms |
4696 KB |
Output is correct |
3 |
Correct |
1 ms |
4444 KB |
Output is correct |
4 |
Correct |
1 ms |
4444 KB |
Output is correct |
5 |
Correct |
1 ms |
4444 KB |
Output is correct |
6 |
Correct |
1 ms |
4440 KB |
Output is correct |
7 |
Correct |
2 ms |
4444 KB |
Output is correct |
8 |
Correct |
1 ms |
4444 KB |
Output is correct |
9 |
Correct |
2 ms |
4836 KB |
Output is correct |
10 |
Correct |
1 ms |
4440 KB |
Output is correct |
11 |
Correct |
1 ms |
4588 KB |
Output is correct |
12 |
Correct |
1 ms |
4440 KB |
Output is correct |
13 |
Correct |
1 ms |
4700 KB |
Output is correct |
14 |
Correct |
1 ms |
4444 KB |
Output is correct |
15 |
Correct |
2 ms |
4444 KB |
Output is correct |
16 |
Correct |
1 ms |
4444 KB |
Output is correct |
17 |
Correct |
1 ms |
4444 KB |
Output is correct |
18 |
Correct |
1 ms |
4444 KB |
Output is correct |
19 |
Correct |
2 ms |
4440 KB |
Output is correct |
20 |
Correct |
1 ms |
4444 KB |
Output is correct |
21 |
Correct |
2 ms |
4444 KB |
Output is correct |
22 |
Correct |
2 ms |
4580 KB |
Output is correct |
23 |
Correct |
2 ms |
4444 KB |
Output is correct |
24 |
Correct |
2 ms |
4444 KB |
Output is correct |
25 |
Correct |
2 ms |
4444 KB |
Output is correct |
26 |
Correct |
1 ms |
4444 KB |
Output is correct |
27 |
Correct |
1 ms |
4444 KB |
Output is correct |
28 |
Correct |
1 ms |
4444 KB |
Output is correct |
29 |
Correct |
1 ms |
4444 KB |
Output is correct |
30 |
Correct |
1 ms |
4444 KB |
Output is correct |
31 |
Correct |
1975 ms |
15920 KB |
Output is correct |
32 |
Correct |
57 ms |
9808 KB |
Output is correct |
33 |
Correct |
149 ms |
11088 KB |
Output is correct |
34 |
Correct |
1499 ms |
11152 KB |
Output is correct |
35 |
Correct |
903 ms |
15864 KB |
Output is correct |
36 |
Correct |
178 ms |
15908 KB |
Output is correct |
37 |
Correct |
136 ms |
9040 KB |
Output is correct |
38 |
Correct |
76 ms |
8824 KB |
Output is correct |
39 |
Correct |
63 ms |
8312 KB |
Output is correct |
40 |
Correct |
63 ms |
8252 KB |
Output is correct |
41 |
Correct |
216 ms |
8676 KB |
Output is correct |
42 |
Correct |
176 ms |
8536 KB |
Output is correct |
43 |
Correct |
483 ms |
15532 KB |
Output is correct |
44 |
Correct |
173 ms |
8528 KB |
Output is correct |
45 |
Correct |
83 ms |
8588 KB |
Output is correct |
46 |
Correct |
48 ms |
8548 KB |
Output is correct |
47 |
Correct |
45 ms |
8148 KB |
Output is correct |
48 |
Correct |
42 ms |
8016 KB |
Output is correct |
49 |
Correct |
53 ms |
8196 KB |
Output is correct |
50 |
Correct |
149 ms |
8548 KB |
Output is correct |
51 |
Correct |
47 ms |
8272 KB |
Output is correct |
52 |
Runtime error |
19 ms |
9820 KB |
Execution killed with signal 11 |
53 |
Halted |
0 ms |
0 KB |
- |