# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
361320 |
2021-01-29T09:49:44 Z |
AmShZ |
New Home (APIO18_new_home) |
C++11 |
|
5000 ms |
66488 KB |
//khodaya khodet komak kon
# include <bits/stdc++.h>
/*
// ordered_set
# include <ext/pb_ds/assoc_container.hpp>
# include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
# define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
*/
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <pii, int> ppi;
typedef pair <int, pii> pip;
typedef pair <pii, pii> ppp;
typedef pair <ll, ll> pll;
# define A first
# define B second
# define endl '\n'
# define sep ' '
# define all(x) x.begin(), x.end()
# define kill(x) return cout << x << endl, 0
# define SZ(x) int(x.size())
# define lc id << 1
# define rc id << 1 | 1
# define InTheNameOfGod ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
ll power(ll a, ll b, ll md) {return (!b ? 1 : (b & 1 ? a * power(a * a % md, b / 2, md) % md : power(a * a % md, b / 2, md) % md));}
const int xn = 3e5 + 10;
const int xm = - 20 + 10;
const int sq = 320;
const int inf = 1e9 + 10;
const ll INF = 1e18 + 10;
const int mod = 998244353;
const int base = 257;
int n, k, q, ans[xn];
ppp a[xn];
pii b[xn];
vector <pip> query;
set <pii> st[xn];
int main(){
InTheNameOfGod;
cin >> n >> k >> q;
for (int i = 1; i <= n; ++ i){
int x, t, l, r;
cin >> x >> t >> l >> r;
a[i] = {{x, t}, {l, r}};
query.push_back({l, {0, i}});
query.push_back({r, {2, i}});
}
for (int i = 1; i <= q; ++ i){
int x, y;
cin >> x >> y;
b[i] = {x, y};
query.push_back({y, {1, i}});
}
for (int i = 1; i <= k; ++ i)
st[i].insert({inf, 0}), st[i].insert({- inf, 0});
sort(all(query));
for (pip Q : query){
int id = Q.B.B, t = Q.B.A;
if (t == 0)
st[a[id].A.B].insert({a[id].A.A, id});
else if (t == 2)
st[a[id].A.B].erase({a[id].A.A, id});
else{
int mx = 0;
for (int i = 1; i <= k; ++ i){
pii x = *st[i].lower_bound({b[id].A, 0});
pii y = *prev(st[i].lower_bound({b[id].A, 0}));
mx = max(mx, min(x.A - b[id].A, b[id].A - y.A));
}
if (mx > 1e8)
ans[id] = - 1;
else
ans[id] = mx;
}
}
for (int i = 1; i <= q; ++ i)
cout << ans[i] << endl;
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
12 ms |
14444 KB |
Output is correct |
4 |
Correct |
10 ms |
14444 KB |
Output is correct |
5 |
Correct |
12 ms |
14444 KB |
Output is correct |
6 |
Correct |
11 ms |
14572 KB |
Output is correct |
7 |
Correct |
12 ms |
14572 KB |
Output is correct |
8 |
Correct |
14 ms |
14572 KB |
Output is correct |
9 |
Correct |
12 ms |
14572 KB |
Output is correct |
10 |
Correct |
11 ms |
14572 KB |
Output is correct |
11 |
Correct |
11 ms |
14572 KB |
Output is correct |
12 |
Correct |
11 ms |
14572 KB |
Output is correct |
13 |
Correct |
11 ms |
14572 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
12 ms |
14572 KB |
Output is correct |
16 |
Correct |
12 ms |
14572 KB |
Output is correct |
17 |
Correct |
11 ms |
14572 KB |
Output is correct |
18 |
Correct |
14 ms |
14572 KB |
Output is correct |
19 |
Correct |
13 ms |
14572 KB |
Output is correct |
20 |
Correct |
11 ms |
14572 KB |
Output is correct |
21 |
Correct |
12 ms |
14572 KB |
Output is correct |
22 |
Correct |
12 ms |
14572 KB |
Output is correct |
23 |
Correct |
12 ms |
14572 KB |
Output is correct |
24 |
Correct |
12 ms |
14592 KB |
Output is correct |
25 |
Correct |
11 ms |
14572 KB |
Output is correct |
26 |
Correct |
10 ms |
14572 KB |
Output is correct |
27 |
Correct |
11 ms |
14444 KB |
Output is correct |
28 |
Correct |
12 ms |
14592 KB |
Output is correct |
29 |
Correct |
13 ms |
14592 KB |
Output is correct |
30 |
Correct |
10 ms |
14572 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
12 ms |
14444 KB |
Output is correct |
4 |
Correct |
10 ms |
14444 KB |
Output is correct |
5 |
Correct |
12 ms |
14444 KB |
Output is correct |
6 |
Correct |
11 ms |
14572 KB |
Output is correct |
7 |
Correct |
12 ms |
14572 KB |
Output is correct |
8 |
Correct |
14 ms |
14572 KB |
Output is correct |
9 |
Correct |
12 ms |
14572 KB |
Output is correct |
10 |
Correct |
11 ms |
14572 KB |
Output is correct |
11 |
Correct |
11 ms |
14572 KB |
Output is correct |
12 |
Correct |
11 ms |
14572 KB |
Output is correct |
13 |
Correct |
11 ms |
14572 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
12 ms |
14572 KB |
Output is correct |
16 |
Correct |
12 ms |
14572 KB |
Output is correct |
17 |
Correct |
11 ms |
14572 KB |
Output is correct |
18 |
Correct |
14 ms |
14572 KB |
Output is correct |
19 |
Correct |
13 ms |
14572 KB |
Output is correct |
20 |
Correct |
11 ms |
14572 KB |
Output is correct |
21 |
Correct |
12 ms |
14572 KB |
Output is correct |
22 |
Correct |
12 ms |
14572 KB |
Output is correct |
23 |
Correct |
12 ms |
14572 KB |
Output is correct |
24 |
Correct |
12 ms |
14592 KB |
Output is correct |
25 |
Correct |
11 ms |
14572 KB |
Output is correct |
26 |
Correct |
10 ms |
14572 KB |
Output is correct |
27 |
Correct |
11 ms |
14444 KB |
Output is correct |
28 |
Correct |
12 ms |
14592 KB |
Output is correct |
29 |
Correct |
13 ms |
14592 KB |
Output is correct |
30 |
Correct |
10 ms |
14572 KB |
Output is correct |
31 |
Correct |
3341 ms |
24532 KB |
Output is correct |
32 |
Correct |
130 ms |
20592 KB |
Output is correct |
33 |
Correct |
250 ms |
22620 KB |
Output is correct |
34 |
Correct |
2440 ms |
22804 KB |
Output is correct |
35 |
Correct |
1476 ms |
24580 KB |
Output is correct |
36 |
Correct |
297 ms |
24284 KB |
Output is correct |
37 |
Correct |
233 ms |
21724 KB |
Output is correct |
38 |
Correct |
127 ms |
21724 KB |
Output is correct |
39 |
Correct |
118 ms |
21616 KB |
Output is correct |
40 |
Correct |
109 ms |
21596 KB |
Output is correct |
41 |
Correct |
432 ms |
21996 KB |
Output is correct |
42 |
Correct |
580 ms |
21596 KB |
Output is correct |
43 |
Correct |
546 ms |
24028 KB |
Output is correct |
44 |
Correct |
359 ms |
21896 KB |
Output is correct |
45 |
Correct |
164 ms |
21852 KB |
Output is correct |
46 |
Correct |
90 ms |
21852 KB |
Output is correct |
47 |
Correct |
85 ms |
21344 KB |
Output is correct |
48 |
Correct |
78 ms |
21340 KB |
Output is correct |
49 |
Correct |
102 ms |
21468 KB |
Output is correct |
50 |
Correct |
336 ms |
21596 KB |
Output is correct |
51 |
Correct |
90 ms |
21596 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5037 ms |
66488 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
5052 ms |
61148 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
12 ms |
14444 KB |
Output is correct |
4 |
Correct |
10 ms |
14444 KB |
Output is correct |
5 |
Correct |
12 ms |
14444 KB |
Output is correct |
6 |
Correct |
11 ms |
14572 KB |
Output is correct |
7 |
Correct |
12 ms |
14572 KB |
Output is correct |
8 |
Correct |
14 ms |
14572 KB |
Output is correct |
9 |
Correct |
12 ms |
14572 KB |
Output is correct |
10 |
Correct |
11 ms |
14572 KB |
Output is correct |
11 |
Correct |
11 ms |
14572 KB |
Output is correct |
12 |
Correct |
11 ms |
14572 KB |
Output is correct |
13 |
Correct |
11 ms |
14572 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
12 ms |
14572 KB |
Output is correct |
16 |
Correct |
12 ms |
14572 KB |
Output is correct |
17 |
Correct |
11 ms |
14572 KB |
Output is correct |
18 |
Correct |
14 ms |
14572 KB |
Output is correct |
19 |
Correct |
13 ms |
14572 KB |
Output is correct |
20 |
Correct |
11 ms |
14572 KB |
Output is correct |
21 |
Correct |
12 ms |
14572 KB |
Output is correct |
22 |
Correct |
12 ms |
14572 KB |
Output is correct |
23 |
Correct |
12 ms |
14572 KB |
Output is correct |
24 |
Correct |
12 ms |
14592 KB |
Output is correct |
25 |
Correct |
11 ms |
14572 KB |
Output is correct |
26 |
Correct |
10 ms |
14572 KB |
Output is correct |
27 |
Correct |
11 ms |
14444 KB |
Output is correct |
28 |
Correct |
12 ms |
14592 KB |
Output is correct |
29 |
Correct |
13 ms |
14592 KB |
Output is correct |
30 |
Correct |
10 ms |
14572 KB |
Output is correct |
31 |
Correct |
3341 ms |
24532 KB |
Output is correct |
32 |
Correct |
130 ms |
20592 KB |
Output is correct |
33 |
Correct |
250 ms |
22620 KB |
Output is correct |
34 |
Correct |
2440 ms |
22804 KB |
Output is correct |
35 |
Correct |
1476 ms |
24580 KB |
Output is correct |
36 |
Correct |
297 ms |
24284 KB |
Output is correct |
37 |
Correct |
233 ms |
21724 KB |
Output is correct |
38 |
Correct |
127 ms |
21724 KB |
Output is correct |
39 |
Correct |
118 ms |
21616 KB |
Output is correct |
40 |
Correct |
109 ms |
21596 KB |
Output is correct |
41 |
Correct |
432 ms |
21996 KB |
Output is correct |
42 |
Correct |
580 ms |
21596 KB |
Output is correct |
43 |
Correct |
546 ms |
24028 KB |
Output is correct |
44 |
Correct |
359 ms |
21896 KB |
Output is correct |
45 |
Correct |
164 ms |
21852 KB |
Output is correct |
46 |
Correct |
90 ms |
21852 KB |
Output is correct |
47 |
Correct |
85 ms |
21344 KB |
Output is correct |
48 |
Correct |
78 ms |
21340 KB |
Output is correct |
49 |
Correct |
102 ms |
21468 KB |
Output is correct |
50 |
Correct |
336 ms |
21596 KB |
Output is correct |
51 |
Correct |
90 ms |
21596 KB |
Output is correct |
52 |
Execution timed out |
5039 ms |
27796 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
14444 KB |
Output is correct |
2 |
Correct |
10 ms |
14444 KB |
Output is correct |
3 |
Correct |
12 ms |
14444 KB |
Output is correct |
4 |
Correct |
10 ms |
14444 KB |
Output is correct |
5 |
Correct |
12 ms |
14444 KB |
Output is correct |
6 |
Correct |
11 ms |
14572 KB |
Output is correct |
7 |
Correct |
12 ms |
14572 KB |
Output is correct |
8 |
Correct |
14 ms |
14572 KB |
Output is correct |
9 |
Correct |
12 ms |
14572 KB |
Output is correct |
10 |
Correct |
11 ms |
14572 KB |
Output is correct |
11 |
Correct |
11 ms |
14572 KB |
Output is correct |
12 |
Correct |
11 ms |
14572 KB |
Output is correct |
13 |
Correct |
11 ms |
14572 KB |
Output is correct |
14 |
Correct |
10 ms |
14444 KB |
Output is correct |
15 |
Correct |
12 ms |
14572 KB |
Output is correct |
16 |
Correct |
12 ms |
14572 KB |
Output is correct |
17 |
Correct |
11 ms |
14572 KB |
Output is correct |
18 |
Correct |
14 ms |
14572 KB |
Output is correct |
19 |
Correct |
13 ms |
14572 KB |
Output is correct |
20 |
Correct |
11 ms |
14572 KB |
Output is correct |
21 |
Correct |
12 ms |
14572 KB |
Output is correct |
22 |
Correct |
12 ms |
14572 KB |
Output is correct |
23 |
Correct |
12 ms |
14572 KB |
Output is correct |
24 |
Correct |
12 ms |
14592 KB |
Output is correct |
25 |
Correct |
11 ms |
14572 KB |
Output is correct |
26 |
Correct |
10 ms |
14572 KB |
Output is correct |
27 |
Correct |
11 ms |
14444 KB |
Output is correct |
28 |
Correct |
12 ms |
14592 KB |
Output is correct |
29 |
Correct |
13 ms |
14592 KB |
Output is correct |
30 |
Correct |
10 ms |
14572 KB |
Output is correct |
31 |
Correct |
3341 ms |
24532 KB |
Output is correct |
32 |
Correct |
130 ms |
20592 KB |
Output is correct |
33 |
Correct |
250 ms |
22620 KB |
Output is correct |
34 |
Correct |
2440 ms |
22804 KB |
Output is correct |
35 |
Correct |
1476 ms |
24580 KB |
Output is correct |
36 |
Correct |
297 ms |
24284 KB |
Output is correct |
37 |
Correct |
233 ms |
21724 KB |
Output is correct |
38 |
Correct |
127 ms |
21724 KB |
Output is correct |
39 |
Correct |
118 ms |
21616 KB |
Output is correct |
40 |
Correct |
109 ms |
21596 KB |
Output is correct |
41 |
Correct |
432 ms |
21996 KB |
Output is correct |
42 |
Correct |
580 ms |
21596 KB |
Output is correct |
43 |
Correct |
546 ms |
24028 KB |
Output is correct |
44 |
Correct |
359 ms |
21896 KB |
Output is correct |
45 |
Correct |
164 ms |
21852 KB |
Output is correct |
46 |
Correct |
90 ms |
21852 KB |
Output is correct |
47 |
Correct |
85 ms |
21344 KB |
Output is correct |
48 |
Correct |
78 ms |
21340 KB |
Output is correct |
49 |
Correct |
102 ms |
21468 KB |
Output is correct |
50 |
Correct |
336 ms |
21596 KB |
Output is correct |
51 |
Correct |
90 ms |
21596 KB |
Output is correct |
52 |
Execution timed out |
5037 ms |
66488 KB |
Time limit exceeded |
53 |
Halted |
0 ms |
0 KB |
- |