# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20649 | 2017-02-13T07:16:29 Z | model_code | None (KOI16_dd) | C++14 | 86 ms | 4740 KB |
#include<stdio.h> #include<algorithm> #include<vector> #include<set> using namespace std; struct lin { int x, y1, y2; bool operator< (const lin& c) const { return x < c.x; } }ba[101010]; struct st { int y, val; bool operator< (const st& c) const { return y < c.y; } }sim; set<st> sets; set<st>::iterator it; int n, sy, tx; int main() { int i; scanf("%d%d%d", &n, &sy, &tx); for (i = 0; i < n; i++)scanf("%d%d%d", &ba[i].x, &ba[i].y1, &ba[i].y2); sort(ba, ba + n); sim = { sy,0 }; sets.insert(sim); for (i = 0; i < n; i++) { st im; int lmin = (int)1e9, rmin = (int)1e9; sim = { ba[i].y1,0 }; it = sets.lower_bound(sim); if (it == sets.end())continue; vector<int> v; for (; it != sets.end(); it++) { im = *it; if (im.y > ba[i].y2)break; v.push_back(im.y); if(im.y < ba[i].y2) lmin = min(lmin, im.val + im.y - ba[i].y1); if(im.y > ba[i].y1) rmin = min(rmin, im.val + ba[i].y2 - im.y); } for (unsigned int j = 0; j < v.size(); j++) sim = { v[j],0 }, sets.erase(sim); if(lmin < (int)1e9) sim = { ba[i].y1,lmin }, sets.insert(sim); if(rmin < (int)1e9) sim = { ba[i].y2,rmin }, sets.insert(sim); } int ans = (int)1e9; for (it = sets.begin(); it != sets.end(); it++) { if (ans > (*it).val)ans = (*it).val; } printf("%d\n", ans + tx); vector<int> v; for (it = sets.begin(); it != sets.end(); it++) { if (ans == (*it).val)v.push_back((*it).y); } printf("%d ", v.size()); for(i = 0; i < v.size(); i++) printf("%d ", v[i]); puts(""); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2364 KB | Output is correct |
2 | Correct | 0 ms | 2364 KB | Output is correct |
3 | Correct | 0 ms | 2364 KB | Output is correct |
4 | Correct | 0 ms | 2364 KB | Output is correct |
5 | Correct | 0 ms | 2364 KB | Output is correct |
6 | Correct | 0 ms | 2364 KB | Output is correct |
7 | Correct | 0 ms | 2364 KB | Output is correct |
8 | Correct | 0 ms | 2364 KB | Output is correct |
9 | Correct | 0 ms | 2364 KB | Output is correct |
10 | Correct | 0 ms | 2364 KB | Output is correct |
11 | Correct | 0 ms | 2364 KB | Output is correct |
12 | Correct | 0 ms | 2364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2364 KB | Output is correct |
2 | Correct | 0 ms | 2364 KB | Output is correct |
3 | Correct | 0 ms | 2364 KB | Output is correct |
4 | Correct | 0 ms | 2364 KB | Output is correct |
5 | Correct | 0 ms | 2364 KB | Output is correct |
6 | Correct | 0 ms | 2364 KB | Output is correct |
7 | Correct | 0 ms | 2364 KB | Output is correct |
8 | Correct | 0 ms | 2364 KB | Output is correct |
9 | Correct | 0 ms | 2364 KB | Output is correct |
10 | Correct | 0 ms | 2364 KB | Output is correct |
11 | Correct | 0 ms | 2364 KB | Output is correct |
12 | Correct | 0 ms | 2364 KB | Output is correct |
13 | Correct | 0 ms | 2364 KB | Output is correct |
14 | Correct | 0 ms | 2364 KB | Output is correct |
15 | Correct | 0 ms | 2364 KB | Output is correct |
16 | Correct | 0 ms | 2364 KB | Output is correct |
17 | Correct | 0 ms | 2364 KB | Output is correct |
18 | Correct | 0 ms | 2364 KB | Output is correct |
19 | Correct | 0 ms | 2364 KB | Output is correct |
20 | Correct | 0 ms | 2364 KB | Output is correct |
21 | Correct | 0 ms | 2364 KB | Output is correct |
22 | Correct | 0 ms | 2364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2364 KB | Output is correct |
2 | Correct | 0 ms | 2364 KB | Output is correct |
3 | Correct | 0 ms | 2364 KB | Output is correct |
4 | Correct | 0 ms | 2364 KB | Output is correct |
5 | Correct | 0 ms | 2364 KB | Output is correct |
6 | Correct | 0 ms | 2364 KB | Output is correct |
7 | Correct | 0 ms | 2364 KB | Output is correct |
8 | Correct | 0 ms | 2364 KB | Output is correct |
9 | Correct | 0 ms | 2364 KB | Output is correct |
10 | Correct | 0 ms | 2364 KB | Output is correct |
11 | Correct | 0 ms | 2364 KB | Output is correct |
12 | Correct | 0 ms | 2364 KB | Output is correct |
13 | Correct | 0 ms | 2364 KB | Output is correct |
14 | Correct | 0 ms | 2364 KB | Output is correct |
15 | Correct | 0 ms | 2364 KB | Output is correct |
16 | Correct | 0 ms | 2364 KB | Output is correct |
17 | Correct | 0 ms | 2364 KB | Output is correct |
18 | Correct | 0 ms | 2364 KB | Output is correct |
19 | Correct | 0 ms | 2364 KB | Output is correct |
20 | Correct | 0 ms | 2364 KB | Output is correct |
21 | Correct | 0 ms | 2364 KB | Output is correct |
22 | Correct | 0 ms | 2364 KB | Output is correct |
23 | Correct | 0 ms | 2364 KB | Output is correct |
24 | Correct | 0 ms | 2364 KB | Output is correct |
25 | Correct | 0 ms | 2364 KB | Output is correct |
26 | Correct | 0 ms | 2364 KB | Output is correct |
27 | Correct | 0 ms | 2364 KB | Output is correct |
28 | Correct | 0 ms | 2364 KB | Output is correct |
29 | Correct | 0 ms | 2364 KB | Output is correct |
30 | Correct | 0 ms | 2364 KB | Output is correct |
31 | Correct | 0 ms | 2364 KB | Output is correct |
32 | Correct | 0 ms | 2364 KB | Output is correct |
33 | Correct | 0 ms | 2364 KB | Output is correct |
34 | Correct | 0 ms | 2364 KB | Output is correct |
35 | Correct | 0 ms | 2364 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 2364 KB | Output is correct |
2 | Correct | 0 ms | 2364 KB | Output is correct |
3 | Correct | 0 ms | 2364 KB | Output is correct |
4 | Correct | 0 ms | 2364 KB | Output is correct |
5 | Correct | 0 ms | 2364 KB | Output is correct |
6 | Correct | 0 ms | 2364 KB | Output is correct |
7 | Correct | 0 ms | 2364 KB | Output is correct |
8 | Correct | 0 ms | 2364 KB | Output is correct |
9 | Correct | 0 ms | 2364 KB | Output is correct |
10 | Correct | 0 ms | 2364 KB | Output is correct |
11 | Correct | 0 ms | 2364 KB | Output is correct |
12 | Correct | 0 ms | 2364 KB | Output is correct |
13 | Correct | 0 ms | 2364 KB | Output is correct |
14 | Correct | 0 ms | 2364 KB | Output is correct |
15 | Correct | 0 ms | 2364 KB | Output is correct |
16 | Correct | 0 ms | 2364 KB | Output is correct |
17 | Correct | 0 ms | 2364 KB | Output is correct |
18 | Correct | 0 ms | 2364 KB | Output is correct |
19 | Correct | 0 ms | 2364 KB | Output is correct |
20 | Correct | 0 ms | 2364 KB | Output is correct |
21 | Correct | 0 ms | 2364 KB | Output is correct |
22 | Correct | 0 ms | 2364 KB | Output is correct |
23 | Correct | 0 ms | 2364 KB | Output is correct |
24 | Correct | 0 ms | 2364 KB | Output is correct |
25 | Correct | 0 ms | 2364 KB | Output is correct |
26 | Correct | 0 ms | 2364 KB | Output is correct |
27 | Correct | 0 ms | 2364 KB | Output is correct |
28 | Correct | 0 ms | 2364 KB | Output is correct |
29 | Correct | 0 ms | 2364 KB | Output is correct |
30 | Correct | 0 ms | 2364 KB | Output is correct |
31 | Correct | 0 ms | 2364 KB | Output is correct |
32 | Correct | 0 ms | 2364 KB | Output is correct |
33 | Correct | 0 ms | 2364 KB | Output is correct |
34 | Correct | 0 ms | 2364 KB | Output is correct |
35 | Correct | 0 ms | 2364 KB | Output is correct |
36 | Correct | 6 ms | 2364 KB | Output is correct |
37 | Correct | 9 ms | 2364 KB | Output is correct |
38 | Correct | 9 ms | 2364 KB | Output is correct |
39 | Correct | 3 ms | 2364 KB | Output is correct |
40 | Correct | 6 ms | 2364 KB | Output is correct |
41 | Correct | 3 ms | 2364 KB | Output is correct |
42 | Correct | 69 ms | 2364 KB | Output is correct |
43 | Correct | 86 ms | 2364 KB | Output is correct |
44 | Correct | 73 ms | 2364 KB | Output is correct |
45 | Correct | 69 ms | 2364 KB | Output is correct |
46 | Correct | 79 ms | 2364 KB | Output is correct |
47 | Correct | 63 ms | 2364 KB | Output is correct |
48 | Correct | 49 ms | 2364 KB | Output is correct |
49 | Correct | 63 ms | 2364 KB | Output is correct |
50 | Correct | 56 ms | 2364 KB | Output is correct |
51 | Correct | 29 ms | 4108 KB | Output is correct |
52 | Correct | 73 ms | 2364 KB | Output is correct |
53 | Correct | 29 ms | 2364 KB | Output is correct |
54 | Correct | 39 ms | 2364 KB | Output is correct |
55 | Correct | 6 ms | 2364 KB | Output is correct |
56 | Correct | 9 ms | 2364 KB | Output is correct |
57 | Correct | 69 ms | 2364 KB | Output is correct |
58 | Correct | 86 ms | 4740 KB | Output is correct |
59 | Correct | 3 ms | 2364 KB | Output is correct |