# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
48849 | 2018-05-19T10:27:48 Z | model_code | 새 집 (APIO18_new_home) | C++17 | 5000 ms | 46480 KB |
#include <bits/stdc++.h> using namespace std; const int INF = (int)1.01e9; void print(vector<int> v) { for (int x : v) printf("%d\n", x); } struct Shop { int x, type, a, b; }; struct Query { int x, time; }; vector<int> slow(vector<Shop> a, int k, vector<Query> b) { int n = a.size(), m = b.size(); vector<int> ans(m); struct Event { int time, type, id; bool operator< (const Event &ev) const { return make_pair(time, -type) < make_pair(ev.time, -ev.type); } }; vector<Event> events; for (int i = 0; i < (int)a.size(); i++) { events.push_back({ a[i].a, +1, i }); events.push_back({ a[i].b, -1, i }); } for (int i = 0; i < (int)b.size(); i++) { events.push_back({ b[i].time, 0, i }); } sort(events.begin(), events.end()); vector<int> sum(k); vector<multiset<int>> st(k); multiset<int> oneShopPos; set<int> noneShopType; for (int i = 0; i < k; i++) noneShopType.insert(i); int empty = k; for (auto ev : events) { if (ev.type == +1) { int tp = a[ev.id].type; if (st[tp].size() == 1) { oneShopPos.erase(oneShopPos.find(*st[tp].begin())); noneShopType.insert(a[ev.id].type); } st[tp].insert(a[ev.id].x); empty -= sum[tp]++ == 0; if (st[tp].size() == 1) { oneShopPos.insert(a[ev.id].x); noneShopType.erase(a[ev.id].type); } } if (ev.type == 0) { int cur = 0; if (empty) cur = INF; for (int i : noneShopType) { int ccur = INF; auto it = st[i].lower_bound(b[ev.id].x); if (it != st[i].end()) ccur = min(ccur, abs(*it - b[ev.id].x)); if (it != st[i].begin()) { it--; ccur = min(ccur, abs(*it - b[ev.id].x)); } cur = max(cur, ccur); if (cur >= INF / 2) break; } if (!oneShopPos.empty()) { cur = max(cur, abs(*oneShopPos.begin() - b[ev.id].x)); cur = max(cur, abs(*oneShopPos.rbegin() - b[ev.id].x)); } if (cur >= INF / 2) cur = -1; ans[ev.id] = cur; } if (ev.type == -1) { int tp = a[ev.id].type; if (st[tp].size() == 1) { oneShopPos.erase(oneShopPos.find(a[ev.id].x)); noneShopType.insert(a[ev.id].type); } st[tp].erase(st[tp].find(a[ev.id].x)); empty += --sum[tp] == 0; if (st[tp].size() == 1) { oneShopPos.insert(*st[tp].begin()); noneShopType.erase(a[ev.id].type); } } } return ans; } int main() { int n, k, q; scanf("%d%d%d", &n, &k, &q); vector<Shop> a(n); for (int i = 0; i < n; i++) { scanf("%d%d%d%d", &a[i].x, &a[i].type, &a[i].a, &a[i].b); a[i].type--; } vector<Query> b(q); for (int i = 0; i < q; i++) scanf("%d%d", &b[i].x, &b[i].time); print(slow(a, k, b)); }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 544 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 3 ms | 576 KB | Output is correct |
7 | Correct | 3 ms | 576 KB | Output is correct |
8 | Correct | 3 ms | 576 KB | Output is correct |
9 | Correct | 2 ms | 576 KB | Output is correct |
10 | Correct | 3 ms | 576 KB | Output is correct |
11 | Correct | 3 ms | 576 KB | Output is correct |
12 | Correct | 3 ms | 732 KB | Output is correct |
13 | Correct | 2 ms | 732 KB | Output is correct |
14 | Correct | 2 ms | 732 KB | Output is correct |
15 | Correct | 3 ms | 732 KB | Output is correct |
16 | Correct | 3 ms | 732 KB | Output is correct |
17 | Correct | 3 ms | 732 KB | Output is correct |
18 | Correct | 2 ms | 732 KB | Output is correct |
19 | Correct | 3 ms | 732 KB | Output is correct |
20 | Correct | 3 ms | 732 KB | Output is correct |
21 | Correct | 3 ms | 732 KB | Output is correct |
22 | Correct | 3 ms | 732 KB | Output is correct |
23 | Correct | 3 ms | 732 KB | Output is correct |
24 | Correct | 3 ms | 732 KB | Output is correct |
25 | Correct | 4 ms | 732 KB | Output is correct |
26 | Correct | 3 ms | 732 KB | Output is correct |
27 | Correct | 3 ms | 732 KB | Output is correct |
28 | Correct | 3 ms | 732 KB | Output is correct |
29 | Correct | 3 ms | 732 KB | Output is correct |
30 | Correct | 3 ms | 732 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 544 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 3 ms | 576 KB | Output is correct |
7 | Correct | 3 ms | 576 KB | Output is correct |
8 | Correct | 3 ms | 576 KB | Output is correct |
9 | Correct | 2 ms | 576 KB | Output is correct |
10 | Correct | 3 ms | 576 KB | Output is correct |
11 | Correct | 3 ms | 576 KB | Output is correct |
12 | Correct | 3 ms | 732 KB | Output is correct |
13 | Correct | 2 ms | 732 KB | Output is correct |
14 | Correct | 2 ms | 732 KB | Output is correct |
15 | Correct | 3 ms | 732 KB | Output is correct |
16 | Correct | 3 ms | 732 KB | Output is correct |
17 | Correct | 3 ms | 732 KB | Output is correct |
18 | Correct | 2 ms | 732 KB | Output is correct |
19 | Correct | 3 ms | 732 KB | Output is correct |
20 | Correct | 3 ms | 732 KB | Output is correct |
21 | Correct | 3 ms | 732 KB | Output is correct |
22 | Correct | 3 ms | 732 KB | Output is correct |
23 | Correct | 3 ms | 732 KB | Output is correct |
24 | Correct | 3 ms | 732 KB | Output is correct |
25 | Correct | 4 ms | 732 KB | Output is correct |
26 | Correct | 3 ms | 732 KB | Output is correct |
27 | Correct | 3 ms | 732 KB | Output is correct |
28 | Correct | 3 ms | 732 KB | Output is correct |
29 | Correct | 3 ms | 732 KB | Output is correct |
30 | Correct | 3 ms | 732 KB | Output is correct |
31 | Correct | 4373 ms | 8740 KB | Output is correct |
32 | Correct | 143 ms | 8740 KB | Output is correct |
33 | Correct | 287 ms | 8740 KB | Output is correct |
34 | Correct | 3361 ms | 8740 KB | Output is correct |
35 | Correct | 1762 ms | 8860 KB | Output is correct |
36 | Correct | 353 ms | 8860 KB | Output is correct |
37 | Correct | 250 ms | 8860 KB | Output is correct |
38 | Correct | 142 ms | 8860 KB | Output is correct |
39 | Correct | 145 ms | 8860 KB | Output is correct |
40 | Correct | 128 ms | 8860 KB | Output is correct |
41 | Correct | 482 ms | 8860 KB | Output is correct |
42 | Correct | 395 ms | 8860 KB | Output is correct |
43 | Correct | 742 ms | 8860 KB | Output is correct |
44 | Correct | 413 ms | 8860 KB | Output is correct |
45 | Correct | 209 ms | 8860 KB | Output is correct |
46 | Correct | 127 ms | 8860 KB | Output is correct |
47 | Correct | 108 ms | 8860 KB | Output is correct |
48 | Correct | 106 ms | 8860 KB | Output is correct |
49 | Correct | 122 ms | 8860 KB | Output is correct |
50 | Correct | 252 ms | 8860 KB | Output is correct |
51 | Correct | 109 ms | 8860 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5013 ms | 46480 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Execution timed out | 5093 ms | 46480 KB | Time limit exceeded |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 544 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 3 ms | 576 KB | Output is correct |
7 | Correct | 3 ms | 576 KB | Output is correct |
8 | Correct | 3 ms | 576 KB | Output is correct |
9 | Correct | 2 ms | 576 KB | Output is correct |
10 | Correct | 3 ms | 576 KB | Output is correct |
11 | Correct | 3 ms | 576 KB | Output is correct |
12 | Correct | 3 ms | 732 KB | Output is correct |
13 | Correct | 2 ms | 732 KB | Output is correct |
14 | Correct | 2 ms | 732 KB | Output is correct |
15 | Correct | 3 ms | 732 KB | Output is correct |
16 | Correct | 3 ms | 732 KB | Output is correct |
17 | Correct | 3 ms | 732 KB | Output is correct |
18 | Correct | 2 ms | 732 KB | Output is correct |
19 | Correct | 3 ms | 732 KB | Output is correct |
20 | Correct | 3 ms | 732 KB | Output is correct |
21 | Correct | 3 ms | 732 KB | Output is correct |
22 | Correct | 3 ms | 732 KB | Output is correct |
23 | Correct | 3 ms | 732 KB | Output is correct |
24 | Correct | 3 ms | 732 KB | Output is correct |
25 | Correct | 4 ms | 732 KB | Output is correct |
26 | Correct | 3 ms | 732 KB | Output is correct |
27 | Correct | 3 ms | 732 KB | Output is correct |
28 | Correct | 3 ms | 732 KB | Output is correct |
29 | Correct | 3 ms | 732 KB | Output is correct |
30 | Correct | 3 ms | 732 KB | Output is correct |
31 | Correct | 4373 ms | 8740 KB | Output is correct |
32 | Correct | 143 ms | 8740 KB | Output is correct |
33 | Correct | 287 ms | 8740 KB | Output is correct |
34 | Correct | 3361 ms | 8740 KB | Output is correct |
35 | Correct | 1762 ms | 8860 KB | Output is correct |
36 | Correct | 353 ms | 8860 KB | Output is correct |
37 | Correct | 250 ms | 8860 KB | Output is correct |
38 | Correct | 142 ms | 8860 KB | Output is correct |
39 | Correct | 145 ms | 8860 KB | Output is correct |
40 | Correct | 128 ms | 8860 KB | Output is correct |
41 | Correct | 482 ms | 8860 KB | Output is correct |
42 | Correct | 395 ms | 8860 KB | Output is correct |
43 | Correct | 742 ms | 8860 KB | Output is correct |
44 | Correct | 413 ms | 8860 KB | Output is correct |
45 | Correct | 209 ms | 8860 KB | Output is correct |
46 | Correct | 127 ms | 8860 KB | Output is correct |
47 | Correct | 108 ms | 8860 KB | Output is correct |
48 | Correct | 106 ms | 8860 KB | Output is correct |
49 | Correct | 122 ms | 8860 KB | Output is correct |
50 | Correct | 252 ms | 8860 KB | Output is correct |
51 | Correct | 109 ms | 8860 KB | Output is correct |
52 | Correct | 289 ms | 46480 KB | Output is correct |
53 | Correct | 298 ms | 46480 KB | Output is correct |
54 | Correct | 230 ms | 46480 KB | Output is correct |
55 | Correct | 514 ms | 46480 KB | Output is correct |
56 | Correct | 468 ms | 46480 KB | Output is correct |
57 | Correct | 519 ms | 46480 KB | Output is correct |
58 | Correct | 522 ms | 46480 KB | Output is correct |
59 | Correct | 428 ms | 46480 KB | Output is correct |
60 | Correct | 527 ms | 46480 KB | Output is correct |
61 | Correct | 118 ms | 46480 KB | Output is correct |
62 | Correct | 262 ms | 46480 KB | Output is correct |
63 | Execution timed out | 5021 ms | 46480 KB | Time limit exceeded |
64 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 488 KB | Output is correct |
3 | Correct | 2 ms | 544 KB | Output is correct |
4 | Correct | 2 ms | 544 KB | Output is correct |
5 | Correct | 2 ms | 576 KB | Output is correct |
6 | Correct | 3 ms | 576 KB | Output is correct |
7 | Correct | 3 ms | 576 KB | Output is correct |
8 | Correct | 3 ms | 576 KB | Output is correct |
9 | Correct | 2 ms | 576 KB | Output is correct |
10 | Correct | 3 ms | 576 KB | Output is correct |
11 | Correct | 3 ms | 576 KB | Output is correct |
12 | Correct | 3 ms | 732 KB | Output is correct |
13 | Correct | 2 ms | 732 KB | Output is correct |
14 | Correct | 2 ms | 732 KB | Output is correct |
15 | Correct | 3 ms | 732 KB | Output is correct |
16 | Correct | 3 ms | 732 KB | Output is correct |
17 | Correct | 3 ms | 732 KB | Output is correct |
18 | Correct | 2 ms | 732 KB | Output is correct |
19 | Correct | 3 ms | 732 KB | Output is correct |
20 | Correct | 3 ms | 732 KB | Output is correct |
21 | Correct | 3 ms | 732 KB | Output is correct |
22 | Correct | 3 ms | 732 KB | Output is correct |
23 | Correct | 3 ms | 732 KB | Output is correct |
24 | Correct | 3 ms | 732 KB | Output is correct |
25 | Correct | 4 ms | 732 KB | Output is correct |
26 | Correct | 3 ms | 732 KB | Output is correct |
27 | Correct | 3 ms | 732 KB | Output is correct |
28 | Correct | 3 ms | 732 KB | Output is correct |
29 | Correct | 3 ms | 732 KB | Output is correct |
30 | Correct | 3 ms | 732 KB | Output is correct |
31 | Correct | 4373 ms | 8740 KB | Output is correct |
32 | Correct | 143 ms | 8740 KB | Output is correct |
33 | Correct | 287 ms | 8740 KB | Output is correct |
34 | Correct | 3361 ms | 8740 KB | Output is correct |
35 | Correct | 1762 ms | 8860 KB | Output is correct |
36 | Correct | 353 ms | 8860 KB | Output is correct |
37 | Correct | 250 ms | 8860 KB | Output is correct |
38 | Correct | 142 ms | 8860 KB | Output is correct |
39 | Correct | 145 ms | 8860 KB | Output is correct |
40 | Correct | 128 ms | 8860 KB | Output is correct |
41 | Correct | 482 ms | 8860 KB | Output is correct |
42 | Correct | 395 ms | 8860 KB | Output is correct |
43 | Correct | 742 ms | 8860 KB | Output is correct |
44 | Correct | 413 ms | 8860 KB | Output is correct |
45 | Correct | 209 ms | 8860 KB | Output is correct |
46 | Correct | 127 ms | 8860 KB | Output is correct |
47 | Correct | 108 ms | 8860 KB | Output is correct |
48 | Correct | 106 ms | 8860 KB | Output is correct |
49 | Correct | 122 ms | 8860 KB | Output is correct |
50 | Correct | 252 ms | 8860 KB | Output is correct |
51 | Correct | 109 ms | 8860 KB | Output is correct |
52 | Execution timed out | 5013 ms | 46480 KB | Time limit exceeded |
53 | Halted | 0 ms | 0 KB | - |