# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
399837 |
2021-05-06T17:45:35 Z |
my99n |
New Home (APIO18_new_home) |
C++17 |
|
2254 ms |
10208 KB |
#include<bits/stdc++.h>
using namespace std;
struct event {
int et, x, t, y, i;
bool operator < (const event & o) const {
if (y == o.y) return et < o.et; // open query close
return y < o.y;
}
};
vector<event> e;
set<pair<int,int>> s[500];
int ans[100100];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int n, k, q; cin >> n >> k >> q;
assert(k < 500);
for (int i = 1; i <= n; i++) {
int x, t, a, b; cin >> x >> t >> a >> b;
e.push_back({1, x, t, a, i});
e.push_back({3, x, t, b, i});
}
for (int i = 1; i <= q; i++) {
int l, y; cin >> l >> y;
e.push_back({2, l, 0, y, i});
}
sort(e.begin(), e.end());
for (auto [et, x, t, y, i] : e) {
if (et == 1) s[t].insert({x, i});
if (et == 3) s[t].erase({x, i});
if (et == 2) {
for (int type = 1; type <= k; type++) {
if (s[type].empty()) {
ans[i] = -1;
break;
}
int mn = 1e9;
// for (auto a = s[type].begin(); a != s[type].end(); a++) {
// mn = min(mn, abs(x - a->first));
// }
// cerr << mn << endl;
auto lb = s[type].lower_bound({x, -1});
if (lb == s[type].end()) lb--;
// cerr << x << ' ' << lb->first << endl;
// assert(mn <= abs(x - (lb->first)));
mn = min(mn, abs(x-(lb->first)));
if (lb != s[type].begin()) lb--;
// assert(mn <= abs(x - (lb->first)));
mn = min(mn, abs(x-(lb->first)));
// if (a != s[type].end()) mn = min(mn, abs(x-(next(a)->first)));
// if (a != s[type].begin()) mn = min(mn, abs(x-(prev(a)->first)));
ans[i] = max(ans[i], mn);
}
}
}
for (int i = 1; i <= q; i++) cout << ans[i] << '\n';
return 0;
}
/*
4 2 4
3 1 1 10
9 2 2 4
7 2 5 7
4 1 8 10
5 3
5 6
5 9
1 10
*/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
408 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
3 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
3 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
372 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
408 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
3 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
3 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
372 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
2254 ms |
7444 KB |
Output is correct |
32 |
Correct |
115 ms |
6452 KB |
Output is correct |
33 |
Correct |
185 ms |
8352 KB |
Output is correct |
34 |
Correct |
1750 ms |
8464 KB |
Output is correct |
35 |
Correct |
1010 ms |
10208 KB |
Output is correct |
36 |
Correct |
214 ms |
10144 KB |
Output is correct |
37 |
Correct |
178 ms |
7772 KB |
Output is correct |
38 |
Correct |
109 ms |
7732 KB |
Output is correct |
39 |
Correct |
94 ms |
7692 KB |
Output is correct |
40 |
Correct |
93 ms |
7684 KB |
Output is correct |
41 |
Correct |
361 ms |
7856 KB |
Output is correct |
42 |
Correct |
248 ms |
7828 KB |
Output is correct |
43 |
Correct |
1113 ms |
9764 KB |
Output is correct |
44 |
Correct |
269 ms |
7740 KB |
Output is correct |
45 |
Correct |
132 ms |
7668 KB |
Output is correct |
46 |
Correct |
79 ms |
7732 KB |
Output is correct |
47 |
Correct |
76 ms |
7848 KB |
Output is correct |
48 |
Correct |
69 ms |
7668 KB |
Output is correct |
49 |
Correct |
86 ms |
7728 KB |
Output is correct |
50 |
Correct |
217 ms |
7680 KB |
Output is correct |
51 |
Correct |
77 ms |
7728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
408 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
3 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
3 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
372 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
2254 ms |
7444 KB |
Output is correct |
32 |
Correct |
115 ms |
6452 KB |
Output is correct |
33 |
Correct |
185 ms |
8352 KB |
Output is correct |
34 |
Correct |
1750 ms |
8464 KB |
Output is correct |
35 |
Correct |
1010 ms |
10208 KB |
Output is correct |
36 |
Correct |
214 ms |
10144 KB |
Output is correct |
37 |
Correct |
178 ms |
7772 KB |
Output is correct |
38 |
Correct |
109 ms |
7732 KB |
Output is correct |
39 |
Correct |
94 ms |
7692 KB |
Output is correct |
40 |
Correct |
93 ms |
7684 KB |
Output is correct |
41 |
Correct |
361 ms |
7856 KB |
Output is correct |
42 |
Correct |
248 ms |
7828 KB |
Output is correct |
43 |
Correct |
1113 ms |
9764 KB |
Output is correct |
44 |
Correct |
269 ms |
7740 KB |
Output is correct |
45 |
Correct |
132 ms |
7668 KB |
Output is correct |
46 |
Correct |
79 ms |
7732 KB |
Output is correct |
47 |
Correct |
76 ms |
7848 KB |
Output is correct |
48 |
Correct |
69 ms |
7668 KB |
Output is correct |
49 |
Correct |
86 ms |
7728 KB |
Output is correct |
50 |
Correct |
217 ms |
7680 KB |
Output is correct |
51 |
Correct |
77 ms |
7728 KB |
Output is correct |
52 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
53 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
2 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
2 ms |
408 KB |
Output is correct |
10 |
Correct |
2 ms |
332 KB |
Output is correct |
11 |
Correct |
1 ms |
332 KB |
Output is correct |
12 |
Correct |
1 ms |
332 KB |
Output is correct |
13 |
Correct |
1 ms |
332 KB |
Output is correct |
14 |
Correct |
1 ms |
332 KB |
Output is correct |
15 |
Correct |
2 ms |
332 KB |
Output is correct |
16 |
Correct |
3 ms |
364 KB |
Output is correct |
17 |
Correct |
2 ms |
332 KB |
Output is correct |
18 |
Correct |
2 ms |
332 KB |
Output is correct |
19 |
Correct |
3 ms |
332 KB |
Output is correct |
20 |
Correct |
2 ms |
332 KB |
Output is correct |
21 |
Correct |
3 ms |
332 KB |
Output is correct |
22 |
Correct |
2 ms |
332 KB |
Output is correct |
23 |
Correct |
2 ms |
332 KB |
Output is correct |
24 |
Correct |
2 ms |
332 KB |
Output is correct |
25 |
Correct |
2 ms |
332 KB |
Output is correct |
26 |
Correct |
2 ms |
332 KB |
Output is correct |
27 |
Correct |
1 ms |
372 KB |
Output is correct |
28 |
Correct |
1 ms |
332 KB |
Output is correct |
29 |
Correct |
1 ms |
336 KB |
Output is correct |
30 |
Correct |
1 ms |
332 KB |
Output is correct |
31 |
Correct |
2254 ms |
7444 KB |
Output is correct |
32 |
Correct |
115 ms |
6452 KB |
Output is correct |
33 |
Correct |
185 ms |
8352 KB |
Output is correct |
34 |
Correct |
1750 ms |
8464 KB |
Output is correct |
35 |
Correct |
1010 ms |
10208 KB |
Output is correct |
36 |
Correct |
214 ms |
10144 KB |
Output is correct |
37 |
Correct |
178 ms |
7772 KB |
Output is correct |
38 |
Correct |
109 ms |
7732 KB |
Output is correct |
39 |
Correct |
94 ms |
7692 KB |
Output is correct |
40 |
Correct |
93 ms |
7684 KB |
Output is correct |
41 |
Correct |
361 ms |
7856 KB |
Output is correct |
42 |
Correct |
248 ms |
7828 KB |
Output is correct |
43 |
Correct |
1113 ms |
9764 KB |
Output is correct |
44 |
Correct |
269 ms |
7740 KB |
Output is correct |
45 |
Correct |
132 ms |
7668 KB |
Output is correct |
46 |
Correct |
79 ms |
7732 KB |
Output is correct |
47 |
Correct |
76 ms |
7848 KB |
Output is correct |
48 |
Correct |
69 ms |
7668 KB |
Output is correct |
49 |
Correct |
86 ms |
7728 KB |
Output is correct |
50 |
Correct |
217 ms |
7680 KB |
Output is correct |
51 |
Correct |
77 ms |
7728 KB |
Output is correct |
52 |
Runtime error |
1 ms |
460 KB |
Execution killed with signal 6 |
53 |
Halted |
0 ms |
0 KB |
- |