#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 340
//#define mp make_pair
#define mid (l+r)/2
#define le node * 2
#define ri node * 2 + 1
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
#define all(x) x.begin(), x.end()
#define gc getchar_unlocked
typedef long long ll;
typedef short int si;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef pair<double,ll>pdi;
const ll inf=1e18;
const ll mod=987654321;
const ld Pi=acos(-1);
int n , k , q ;
int x [400009] , t [400009] , l [400009] , r [400009] ;
pair < pi , int > que [400009] ;
int ANS [400009] ;
map < int , int > mp ;
vi in [400009] , out [400009] , query [400009] ;
multiset < int > s [400009] ;
int main () {
cin >> n >> k >> q ;
set < int > st ;
for ( int i = 0 ; i < n ; i ++ ) {
cin >> x [i] >> t [i] >> l [i] >> r [i] ;
st .ins ( l [i] ) ;
st .ins ( r [i] ) ;
}
for ( int i = 0 ; i < q ; i ++ ) {
cin >> que [i] .fi.se >> que [i] .fi.fi ;
que [i] .se = i ;
st .ins ( que [i] .fi.fi ) ;
}
sort ( que , que + q ) ;
int N = 0 ;
for ( auto u : st ) mp [u] = N ++ ;
for ( int i = 0 ; i < n ; i ++ ) {
l [i] = mp [l[i]] ;
r [i] = mp [r[i]] ;
in [l[i]] .pb ( i ) ;
out[r[i]] .pb ( i ) ;
}
for ( int i = 0 ; i < q ; i ++ ) {
que [i] .fi.fi = mp [ que [i] .fi.fi ] ;
query [ que [i] .fi.fi ] .pb ( i ) ;
}
/* for ( int i = 0 ; i < n ; i ++ ) {
cout << x [i] << " " << t [i] << " " << l [i] << " " << r [i] << endl ;
}
cout << endl ;
for ( int i = 0 ; i < q ; i ++ ) {
cout << que [i] .fi.fi << endl ;
}
cout << endl ;
cout << N << endl ;
*/
for ( int i = 0 ; i < N ; i ++ ) {
for ( auto u : in [i] ) {
s [t[u]] .ins ( x [u] ) ;
// cout << u << " " ;
}
// cout << " || " ;
for ( auto u : query [i] ) {
int loc = que [u] .fi.se , id = que [u] .se , ans = 0 ;
// cout << id << " " ;
for ( int j = 1 ; j <= k ; j ++ ) {
int crnt = 1e9 ;
auto af = s [j] .lb ( loc ) ;
if ( af != s [j] .end () ) {
crnt = min ( crnt , abs ( *af - loc ) ) ;
}
auto bf = s [j] .ub ( loc ) ;
if ( bf != s [j] .begin () ) {
bf -- ;
crnt = min ( crnt , abs ( *bf - loc ) ) ;
}
ans = max ( ans , crnt ) ;
}
ANS [id] = ( ans == 1e9 ? -1 : ans ) ;
}
// cout << " || " ;
for ( auto u : out [i] ) {
s [t[u]] .era ( s[t[u]].find (x [u]) ) ;
// cout << u << " " ;
}
// cout << endl ;
}
for ( int i = 0 ; i < q ; i ++ ) cout << ANS [i] << endl ;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47352 KB |
Output is correct |
2 |
Correct |
28 ms |
47360 KB |
Output is correct |
3 |
Correct |
28 ms |
47360 KB |
Output is correct |
4 |
Correct |
34 ms |
47352 KB |
Output is correct |
5 |
Correct |
30 ms |
47360 KB |
Output is correct |
6 |
Correct |
31 ms |
47480 KB |
Output is correct |
7 |
Correct |
37 ms |
47440 KB |
Output is correct |
8 |
Correct |
31 ms |
47488 KB |
Output is correct |
9 |
Correct |
32 ms |
47480 KB |
Output is correct |
10 |
Correct |
34 ms |
47608 KB |
Output is correct |
11 |
Correct |
31 ms |
47488 KB |
Output is correct |
12 |
Correct |
37 ms |
47488 KB |
Output is correct |
13 |
Correct |
30 ms |
47480 KB |
Output is correct |
14 |
Correct |
30 ms |
47488 KB |
Output is correct |
15 |
Correct |
37 ms |
47488 KB |
Output is correct |
16 |
Correct |
38 ms |
47480 KB |
Output is correct |
17 |
Correct |
32 ms |
47488 KB |
Output is correct |
18 |
Correct |
31 ms |
47480 KB |
Output is correct |
19 |
Correct |
33 ms |
47488 KB |
Output is correct |
20 |
Correct |
37 ms |
47480 KB |
Output is correct |
21 |
Correct |
32 ms |
47360 KB |
Output is correct |
22 |
Correct |
32 ms |
47480 KB |
Output is correct |
23 |
Correct |
31 ms |
47480 KB |
Output is correct |
24 |
Correct |
31 ms |
47480 KB |
Output is correct |
25 |
Correct |
31 ms |
47488 KB |
Output is correct |
26 |
Correct |
31 ms |
47488 KB |
Output is correct |
27 |
Correct |
30 ms |
47360 KB |
Output is correct |
28 |
Correct |
30 ms |
47484 KB |
Output is correct |
29 |
Correct |
32 ms |
47480 KB |
Output is correct |
30 |
Correct |
31 ms |
47488 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47352 KB |
Output is correct |
2 |
Correct |
28 ms |
47360 KB |
Output is correct |
3 |
Correct |
28 ms |
47360 KB |
Output is correct |
4 |
Correct |
34 ms |
47352 KB |
Output is correct |
5 |
Correct |
30 ms |
47360 KB |
Output is correct |
6 |
Correct |
31 ms |
47480 KB |
Output is correct |
7 |
Correct |
37 ms |
47440 KB |
Output is correct |
8 |
Correct |
31 ms |
47488 KB |
Output is correct |
9 |
Correct |
32 ms |
47480 KB |
Output is correct |
10 |
Correct |
34 ms |
47608 KB |
Output is correct |
11 |
Correct |
31 ms |
47488 KB |
Output is correct |
12 |
Correct |
37 ms |
47488 KB |
Output is correct |
13 |
Correct |
30 ms |
47480 KB |
Output is correct |
14 |
Correct |
30 ms |
47488 KB |
Output is correct |
15 |
Correct |
37 ms |
47488 KB |
Output is correct |
16 |
Correct |
38 ms |
47480 KB |
Output is correct |
17 |
Correct |
32 ms |
47488 KB |
Output is correct |
18 |
Correct |
31 ms |
47480 KB |
Output is correct |
19 |
Correct |
33 ms |
47488 KB |
Output is correct |
20 |
Correct |
37 ms |
47480 KB |
Output is correct |
21 |
Correct |
32 ms |
47360 KB |
Output is correct |
22 |
Correct |
32 ms |
47480 KB |
Output is correct |
23 |
Correct |
31 ms |
47480 KB |
Output is correct |
24 |
Correct |
31 ms |
47480 KB |
Output is correct |
25 |
Correct |
31 ms |
47488 KB |
Output is correct |
26 |
Correct |
31 ms |
47488 KB |
Output is correct |
27 |
Correct |
30 ms |
47360 KB |
Output is correct |
28 |
Correct |
30 ms |
47484 KB |
Output is correct |
29 |
Correct |
32 ms |
47480 KB |
Output is correct |
30 |
Correct |
31 ms |
47488 KB |
Output is correct |
31 |
Correct |
3627 ms |
76588 KB |
Output is correct |
32 |
Correct |
297 ms |
52216 KB |
Output is correct |
33 |
Correct |
772 ms |
74724 KB |
Output is correct |
34 |
Correct |
2723 ms |
74832 KB |
Output is correct |
35 |
Correct |
1906 ms |
76756 KB |
Output is correct |
36 |
Correct |
792 ms |
76564 KB |
Output is correct |
37 |
Correct |
672 ms |
73976 KB |
Output is correct |
38 |
Correct |
545 ms |
73720 KB |
Output is correct |
39 |
Correct |
526 ms |
73592 KB |
Output is correct |
40 |
Correct |
518 ms |
73592 KB |
Output is correct |
41 |
Correct |
791 ms |
73976 KB |
Output is correct |
42 |
Correct |
903 ms |
73848 KB |
Output is correct |
43 |
Correct |
588 ms |
54684 KB |
Output is correct |
44 |
Correct |
738 ms |
73976 KB |
Output is correct |
45 |
Correct |
590 ms |
73976 KB |
Output is correct |
46 |
Correct |
523 ms |
73848 KB |
Output is correct |
47 |
Correct |
462 ms |
72824 KB |
Output is correct |
48 |
Correct |
455 ms |
72696 KB |
Output is correct |
49 |
Correct |
490 ms |
73208 KB |
Output is correct |
50 |
Correct |
680 ms |
73592 KB |
Output is correct |
51 |
Correct |
469 ms |
73084 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
5071 ms |
112984 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
2618 ms |
264192 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47352 KB |
Output is correct |
2 |
Correct |
28 ms |
47360 KB |
Output is correct |
3 |
Correct |
28 ms |
47360 KB |
Output is correct |
4 |
Correct |
34 ms |
47352 KB |
Output is correct |
5 |
Correct |
30 ms |
47360 KB |
Output is correct |
6 |
Correct |
31 ms |
47480 KB |
Output is correct |
7 |
Correct |
37 ms |
47440 KB |
Output is correct |
8 |
Correct |
31 ms |
47488 KB |
Output is correct |
9 |
Correct |
32 ms |
47480 KB |
Output is correct |
10 |
Correct |
34 ms |
47608 KB |
Output is correct |
11 |
Correct |
31 ms |
47488 KB |
Output is correct |
12 |
Correct |
37 ms |
47488 KB |
Output is correct |
13 |
Correct |
30 ms |
47480 KB |
Output is correct |
14 |
Correct |
30 ms |
47488 KB |
Output is correct |
15 |
Correct |
37 ms |
47488 KB |
Output is correct |
16 |
Correct |
38 ms |
47480 KB |
Output is correct |
17 |
Correct |
32 ms |
47488 KB |
Output is correct |
18 |
Correct |
31 ms |
47480 KB |
Output is correct |
19 |
Correct |
33 ms |
47488 KB |
Output is correct |
20 |
Correct |
37 ms |
47480 KB |
Output is correct |
21 |
Correct |
32 ms |
47360 KB |
Output is correct |
22 |
Correct |
32 ms |
47480 KB |
Output is correct |
23 |
Correct |
31 ms |
47480 KB |
Output is correct |
24 |
Correct |
31 ms |
47480 KB |
Output is correct |
25 |
Correct |
31 ms |
47488 KB |
Output is correct |
26 |
Correct |
31 ms |
47488 KB |
Output is correct |
27 |
Correct |
30 ms |
47360 KB |
Output is correct |
28 |
Correct |
30 ms |
47484 KB |
Output is correct |
29 |
Correct |
32 ms |
47480 KB |
Output is correct |
30 |
Correct |
31 ms |
47488 KB |
Output is correct |
31 |
Correct |
3627 ms |
76588 KB |
Output is correct |
32 |
Correct |
297 ms |
52216 KB |
Output is correct |
33 |
Correct |
772 ms |
74724 KB |
Output is correct |
34 |
Correct |
2723 ms |
74832 KB |
Output is correct |
35 |
Correct |
1906 ms |
76756 KB |
Output is correct |
36 |
Correct |
792 ms |
76564 KB |
Output is correct |
37 |
Correct |
672 ms |
73976 KB |
Output is correct |
38 |
Correct |
545 ms |
73720 KB |
Output is correct |
39 |
Correct |
526 ms |
73592 KB |
Output is correct |
40 |
Correct |
518 ms |
73592 KB |
Output is correct |
41 |
Correct |
791 ms |
73976 KB |
Output is correct |
42 |
Correct |
903 ms |
73848 KB |
Output is correct |
43 |
Correct |
588 ms |
54684 KB |
Output is correct |
44 |
Correct |
738 ms |
73976 KB |
Output is correct |
45 |
Correct |
590 ms |
73976 KB |
Output is correct |
46 |
Correct |
523 ms |
73848 KB |
Output is correct |
47 |
Correct |
462 ms |
72824 KB |
Output is correct |
48 |
Correct |
455 ms |
72696 KB |
Output is correct |
49 |
Correct |
490 ms |
73208 KB |
Output is correct |
50 |
Correct |
680 ms |
73592 KB |
Output is correct |
51 |
Correct |
469 ms |
73084 KB |
Output is correct |
52 |
Execution timed out |
5088 ms |
74636 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
28 ms |
47352 KB |
Output is correct |
2 |
Correct |
28 ms |
47360 KB |
Output is correct |
3 |
Correct |
28 ms |
47360 KB |
Output is correct |
4 |
Correct |
34 ms |
47352 KB |
Output is correct |
5 |
Correct |
30 ms |
47360 KB |
Output is correct |
6 |
Correct |
31 ms |
47480 KB |
Output is correct |
7 |
Correct |
37 ms |
47440 KB |
Output is correct |
8 |
Correct |
31 ms |
47488 KB |
Output is correct |
9 |
Correct |
32 ms |
47480 KB |
Output is correct |
10 |
Correct |
34 ms |
47608 KB |
Output is correct |
11 |
Correct |
31 ms |
47488 KB |
Output is correct |
12 |
Correct |
37 ms |
47488 KB |
Output is correct |
13 |
Correct |
30 ms |
47480 KB |
Output is correct |
14 |
Correct |
30 ms |
47488 KB |
Output is correct |
15 |
Correct |
37 ms |
47488 KB |
Output is correct |
16 |
Correct |
38 ms |
47480 KB |
Output is correct |
17 |
Correct |
32 ms |
47488 KB |
Output is correct |
18 |
Correct |
31 ms |
47480 KB |
Output is correct |
19 |
Correct |
33 ms |
47488 KB |
Output is correct |
20 |
Correct |
37 ms |
47480 KB |
Output is correct |
21 |
Correct |
32 ms |
47360 KB |
Output is correct |
22 |
Correct |
32 ms |
47480 KB |
Output is correct |
23 |
Correct |
31 ms |
47480 KB |
Output is correct |
24 |
Correct |
31 ms |
47480 KB |
Output is correct |
25 |
Correct |
31 ms |
47488 KB |
Output is correct |
26 |
Correct |
31 ms |
47488 KB |
Output is correct |
27 |
Correct |
30 ms |
47360 KB |
Output is correct |
28 |
Correct |
30 ms |
47484 KB |
Output is correct |
29 |
Correct |
32 ms |
47480 KB |
Output is correct |
30 |
Correct |
31 ms |
47488 KB |
Output is correct |
31 |
Correct |
3627 ms |
76588 KB |
Output is correct |
32 |
Correct |
297 ms |
52216 KB |
Output is correct |
33 |
Correct |
772 ms |
74724 KB |
Output is correct |
34 |
Correct |
2723 ms |
74832 KB |
Output is correct |
35 |
Correct |
1906 ms |
76756 KB |
Output is correct |
36 |
Correct |
792 ms |
76564 KB |
Output is correct |
37 |
Correct |
672 ms |
73976 KB |
Output is correct |
38 |
Correct |
545 ms |
73720 KB |
Output is correct |
39 |
Correct |
526 ms |
73592 KB |
Output is correct |
40 |
Correct |
518 ms |
73592 KB |
Output is correct |
41 |
Correct |
791 ms |
73976 KB |
Output is correct |
42 |
Correct |
903 ms |
73848 KB |
Output is correct |
43 |
Correct |
588 ms |
54684 KB |
Output is correct |
44 |
Correct |
738 ms |
73976 KB |
Output is correct |
45 |
Correct |
590 ms |
73976 KB |
Output is correct |
46 |
Correct |
523 ms |
73848 KB |
Output is correct |
47 |
Correct |
462 ms |
72824 KB |
Output is correct |
48 |
Correct |
455 ms |
72696 KB |
Output is correct |
49 |
Correct |
490 ms |
73208 KB |
Output is correct |
50 |
Correct |
680 ms |
73592 KB |
Output is correct |
51 |
Correct |
469 ms |
73084 KB |
Output is correct |
52 |
Execution timed out |
5071 ms |
112984 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |