# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
20414 | 2017-02-11T07:59:19 Z | tlwpdus(#44, tlwpdus) | Can polan into space? (OJUZ11_space) | C++ | 183 ms | 22988 KB |
#include<stdio.h> #include<algorithm> #include<vector> #include<math.h> #include<queue> using namespace std; typedef long long ll; int n; ll str[200100][3]; ll dyn[200100][2]; int via[200100][2]; vector<int> lis[200100]; int deg[200100]; queue<int> q; int main() { int i, j; scanf("%d",&n); for (i=0;i<n;i++) { for (j=0;j<3;j++) scanf("%d",&str[i][j]); } dyn[0][0] = str[0][0]; dyn[0][1] = str[0][1]; for (i=1;i<n;i++) { if (dyn[i-1][0]+str[i][1]<dyn[i-1][1]+str[i][0]) dyn[i][0] = dyn[i-1][1]+str[i][0], via[i][0] = 1; else dyn[i][0] = dyn[i-1][0]+str[i][1], via[i][0] = 0; if (i==n-1) continue; if (dyn[i-1][0]+str[i][2]<dyn[i-1][1]+str[i][1]) dyn[i][1] = dyn[i-1][1]+str[i][1], via[i][1] = 1; else dyn[i][1] = dyn[i-1][0]+str[i][2], via[i][1] = 0; } int p = 0; for (i=n-1;i>0;i--) { p = via[i][p]; if (p) {lis[i].push_back(i-1),deg[i-1]++;} else {lis[i-1].push_back(i),deg[i]++;} } for (i=0;i<n;i++) if (!deg[i]) q.push(i); printf("%lld\n",dyn[n-1][0]); while(!q.empty()) { int here = q.front(); q.pop(); printf("%d ",here+1); for (i=0;i<lis[here].size();i++) { int there = lis[here][i]; deg[there]--; if (!deg[there]) q.push(there); } } printf("\n"); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 16784 KB | Output is correct |
2 | Correct | 0 ms | 16784 KB | Output is correct |
3 | Correct | 3 ms | 16784 KB | Output is correct |
4 | Correct | 0 ms | 16784 KB | Output is correct |
5 | Correct | 0 ms | 16784 KB | Output is correct |
6 | Correct | 0 ms | 16784 KB | Output is correct |
7 | Correct | 0 ms | 16784 KB | Output is correct |
8 | Correct | 0 ms | 16784 KB | Output is correct |
9 | Correct | 0 ms | 16784 KB | Output is correct |
10 | Correct | 0 ms | 16784 KB | Output is correct |
11 | Correct | 3 ms | 16784 KB | Output is correct |
12 | Correct | 0 ms | 16784 KB | Output is correct |
13 | Correct | 3 ms | 16784 KB | Output is correct |
14 | Correct | 3 ms | 16784 KB | Output is correct |
15 | Correct | 0 ms | 16784 KB | Output is correct |
16 | Correct | 0 ms | 16784 KB | Output is correct |
17 | Correct | 0 ms | 16784 KB | Output is correct |
18 | Correct | 3 ms | 16784 KB | Output is correct |
19 | Correct | 3 ms | 16784 KB | Output is correct |
20 | Correct | 3 ms | 16784 KB | Output is correct |
21 | Correct | 3 ms | 16784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 16784 KB | Output is correct |
2 | Correct | 0 ms | 16784 KB | Output is correct |
3 | Correct | 3 ms | 16784 KB | Output is correct |
4 | Correct | 0 ms | 16784 KB | Output is correct |
5 | Correct | 0 ms | 16784 KB | Output is correct |
6 | Correct | 0 ms | 16784 KB | Output is correct |
7 | Correct | 0 ms | 16784 KB | Output is correct |
8 | Correct | 0 ms | 16784 KB | Output is correct |
9 | Correct | 0 ms | 16784 KB | Output is correct |
10 | Correct | 0 ms | 16784 KB | Output is correct |
11 | Correct | 3 ms | 16784 KB | Output is correct |
12 | Correct | 0 ms | 16784 KB | Output is correct |
13 | Correct | 3 ms | 16784 KB | Output is correct |
14 | Correct | 3 ms | 16784 KB | Output is correct |
15 | Correct | 0 ms | 16784 KB | Output is correct |
16 | Correct | 0 ms | 16784 KB | Output is correct |
17 | Correct | 0 ms | 16784 KB | Output is correct |
18 | Correct | 3 ms | 16784 KB | Output is correct |
19 | Correct | 3 ms | 16784 KB | Output is correct |
20 | Correct | 3 ms | 16784 KB | Output is correct |
21 | Correct | 3 ms | 16784 KB | Output is correct |
22 | Correct | 3 ms | 16784 KB | Output is correct |
23 | Correct | 0 ms | 16784 KB | Output is correct |
24 | Correct | 0 ms | 16784 KB | Output is correct |
25 | Correct | 0 ms | 16784 KB | Output is correct |
26 | Correct | 0 ms | 16784 KB | Output is correct |
27 | Correct | 0 ms | 16784 KB | Output is correct |
28 | Correct | 0 ms | 16784 KB | Output is correct |
29 | Correct | 3 ms | 16784 KB | Output is correct |
30 | Correct | 3 ms | 16784 KB | Output is correct |
31 | Correct | 3 ms | 16784 KB | Output is correct |
32 | Correct | 0 ms | 16784 KB | Output is correct |
33 | Correct | 0 ms | 16784 KB | Output is correct |
34 | Correct | 0 ms | 16784 KB | Output is correct |
35 | Correct | 3 ms | 16784 KB | Output is correct |
36 | Correct | 0 ms | 16784 KB | Output is correct |
37 | Correct | 3 ms | 16784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 16784 KB | Output is correct |
2 | Correct | 0 ms | 16784 KB | Output is correct |
3 | Correct | 3 ms | 16784 KB | Output is correct |
4 | Correct | 0 ms | 16784 KB | Output is correct |
5 | Correct | 0 ms | 16784 KB | Output is correct |
6 | Correct | 0 ms | 16784 KB | Output is correct |
7 | Correct | 0 ms | 16784 KB | Output is correct |
8 | Correct | 0 ms | 16784 KB | Output is correct |
9 | Correct | 0 ms | 16784 KB | Output is correct |
10 | Correct | 0 ms | 16784 KB | Output is correct |
11 | Correct | 3 ms | 16784 KB | Output is correct |
12 | Correct | 0 ms | 16784 KB | Output is correct |
13 | Correct | 3 ms | 16784 KB | Output is correct |
14 | Correct | 3 ms | 16784 KB | Output is correct |
15 | Correct | 0 ms | 16784 KB | Output is correct |
16 | Correct | 0 ms | 16784 KB | Output is correct |
17 | Correct | 0 ms | 16784 KB | Output is correct |
18 | Correct | 3 ms | 16784 KB | Output is correct |
19 | Correct | 3 ms | 16784 KB | Output is correct |
20 | Correct | 3 ms | 16784 KB | Output is correct |
21 | Correct | 3 ms | 16784 KB | Output is correct |
22 | Correct | 3 ms | 16784 KB | Output is correct |
23 | Correct | 0 ms | 16784 KB | Output is correct |
24 | Correct | 0 ms | 16784 KB | Output is correct |
25 | Correct | 0 ms | 16784 KB | Output is correct |
26 | Correct | 0 ms | 16784 KB | Output is correct |
27 | Correct | 0 ms | 16784 KB | Output is correct |
28 | Correct | 0 ms | 16784 KB | Output is correct |
29 | Correct | 3 ms | 16784 KB | Output is correct |
30 | Correct | 3 ms | 16784 KB | Output is correct |
31 | Correct | 3 ms | 16784 KB | Output is correct |
32 | Correct | 0 ms | 16784 KB | Output is correct |
33 | Correct | 0 ms | 16784 KB | Output is correct |
34 | Correct | 0 ms | 16784 KB | Output is correct |
35 | Correct | 3 ms | 16784 KB | Output is correct |
36 | Correct | 0 ms | 16784 KB | Output is correct |
37 | Correct | 3 ms | 16784 KB | Output is correct |
38 | Correct | 3 ms | 16784 KB | Output is correct |
39 | Correct | 3 ms | 16784 KB | Output is correct |
40 | Correct | 3 ms | 16784 KB | Output is correct |
41 | Correct | 3 ms | 16784 KB | Output is correct |
42 | Correct | 3 ms | 16784 KB | Output is correct |
43 | Correct | 0 ms | 16784 KB | Output is correct |
44 | Correct | 3 ms | 16784 KB | Output is correct |
45 | Correct | 0 ms | 16784 KB | Output is correct |
46 | Correct | 0 ms | 16784 KB | Output is correct |
47 | Correct | 0 ms | 16784 KB | Output is correct |
48 | Correct | 0 ms | 16784 KB | Output is correct |
49 | Correct | 0 ms | 16784 KB | Output is correct |
50 | Correct | 0 ms | 16784 KB | Output is correct |
51 | Correct | 0 ms | 16784 KB | Output is correct |
52 | Correct | 0 ms | 16784 KB | Output is correct |
53 | Correct | 0 ms | 16784 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 16784 KB | Output is correct |
2 | Correct | 0 ms | 16784 KB | Output is correct |
3 | Correct | 3 ms | 16784 KB | Output is correct |
4 | Correct | 0 ms | 16784 KB | Output is correct |
5 | Correct | 0 ms | 16784 KB | Output is correct |
6 | Correct | 0 ms | 16784 KB | Output is correct |
7 | Correct | 0 ms | 16784 KB | Output is correct |
8 | Correct | 0 ms | 16784 KB | Output is correct |
9 | Correct | 0 ms | 16784 KB | Output is correct |
10 | Correct | 0 ms | 16784 KB | Output is correct |
11 | Correct | 3 ms | 16784 KB | Output is correct |
12 | Correct | 0 ms | 16784 KB | Output is correct |
13 | Correct | 3 ms | 16784 KB | Output is correct |
14 | Correct | 3 ms | 16784 KB | Output is correct |
15 | Correct | 0 ms | 16784 KB | Output is correct |
16 | Correct | 0 ms | 16784 KB | Output is correct |
17 | Correct | 0 ms | 16784 KB | Output is correct |
18 | Correct | 3 ms | 16784 KB | Output is correct |
19 | Correct | 3 ms | 16784 KB | Output is correct |
20 | Correct | 3 ms | 16784 KB | Output is correct |
21 | Correct | 3 ms | 16784 KB | Output is correct |
22 | Correct | 3 ms | 16784 KB | Output is correct |
23 | Correct | 0 ms | 16784 KB | Output is correct |
24 | Correct | 0 ms | 16784 KB | Output is correct |
25 | Correct | 0 ms | 16784 KB | Output is correct |
26 | Correct | 0 ms | 16784 KB | Output is correct |
27 | Correct | 0 ms | 16784 KB | Output is correct |
28 | Correct | 0 ms | 16784 KB | Output is correct |
29 | Correct | 3 ms | 16784 KB | Output is correct |
30 | Correct | 3 ms | 16784 KB | Output is correct |
31 | Correct | 3 ms | 16784 KB | Output is correct |
32 | Correct | 0 ms | 16784 KB | Output is correct |
33 | Correct | 0 ms | 16784 KB | Output is correct |
34 | Correct | 0 ms | 16784 KB | Output is correct |
35 | Correct | 3 ms | 16784 KB | Output is correct |
36 | Correct | 0 ms | 16784 KB | Output is correct |
37 | Correct | 3 ms | 16784 KB | Output is correct |
38 | Correct | 3 ms | 16784 KB | Output is correct |
39 | Correct | 3 ms | 16784 KB | Output is correct |
40 | Correct | 3 ms | 16784 KB | Output is correct |
41 | Correct | 3 ms | 16784 KB | Output is correct |
42 | Correct | 3 ms | 16784 KB | Output is correct |
43 | Correct | 0 ms | 16784 KB | Output is correct |
44 | Correct | 3 ms | 16784 KB | Output is correct |
45 | Correct | 0 ms | 16784 KB | Output is correct |
46 | Correct | 0 ms | 16784 KB | Output is correct |
47 | Correct | 0 ms | 16784 KB | Output is correct |
48 | Correct | 0 ms | 16784 KB | Output is correct |
49 | Correct | 0 ms | 16784 KB | Output is correct |
50 | Correct | 0 ms | 16784 KB | Output is correct |
51 | Correct | 0 ms | 16784 KB | Output is correct |
52 | Correct | 0 ms | 16784 KB | Output is correct |
53 | Correct | 0 ms | 16784 KB | Output is correct |
54 | Correct | 3 ms | 16784 KB | Output is correct |
55 | Correct | 13 ms | 17048 KB | Output is correct |
56 | Correct | 6 ms | 17048 KB | Output is correct |
57 | Correct | 6 ms | 17048 KB | Output is correct |
58 | Correct | 6 ms | 17048 KB | Output is correct |
59 | Correct | 3 ms | 17048 KB | Output is correct |
60 | Correct | 6 ms | 17048 KB | Output is correct |
61 | Correct | 0 ms | 17048 KB | Output is correct |
62 | Correct | 3 ms | 16916 KB | Output is correct |
63 | Correct | 0 ms | 16784 KB | Output is correct |
64 | Correct | 6 ms | 17048 KB | Output is correct |
65 | Correct | 9 ms | 17048 KB | Output is correct |
66 | Correct | 6 ms | 17048 KB | Output is correct |
67 | Correct | 6 ms | 16916 KB | Output is correct |
68 | Correct | 6 ms | 16916 KB | Output is correct |
69 | Correct | 6 ms | 16916 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 16784 KB | Output is correct |
2 | Correct | 0 ms | 16784 KB | Output is correct |
3 | Correct | 3 ms | 16784 KB | Output is correct |
4 | Correct | 0 ms | 16784 KB | Output is correct |
5 | Correct | 0 ms | 16784 KB | Output is correct |
6 | Correct | 0 ms | 16784 KB | Output is correct |
7 | Correct | 0 ms | 16784 KB | Output is correct |
8 | Correct | 0 ms | 16784 KB | Output is correct |
9 | Correct | 0 ms | 16784 KB | Output is correct |
10 | Correct | 0 ms | 16784 KB | Output is correct |
11 | Correct | 3 ms | 16784 KB | Output is correct |
12 | Correct | 0 ms | 16784 KB | Output is correct |
13 | Correct | 3 ms | 16784 KB | Output is correct |
14 | Correct | 3 ms | 16784 KB | Output is correct |
15 | Correct | 0 ms | 16784 KB | Output is correct |
16 | Correct | 0 ms | 16784 KB | Output is correct |
17 | Correct | 0 ms | 16784 KB | Output is correct |
18 | Correct | 3 ms | 16784 KB | Output is correct |
19 | Correct | 3 ms | 16784 KB | Output is correct |
20 | Correct | 3 ms | 16784 KB | Output is correct |
21 | Correct | 3 ms | 16784 KB | Output is correct |
22 | Correct | 3 ms | 16784 KB | Output is correct |
23 | Correct | 0 ms | 16784 KB | Output is correct |
24 | Correct | 0 ms | 16784 KB | Output is correct |
25 | Correct | 0 ms | 16784 KB | Output is correct |
26 | Correct | 0 ms | 16784 KB | Output is correct |
27 | Correct | 0 ms | 16784 KB | Output is correct |
28 | Correct | 0 ms | 16784 KB | Output is correct |
29 | Correct | 3 ms | 16784 KB | Output is correct |
30 | Correct | 3 ms | 16784 KB | Output is correct |
31 | Correct | 3 ms | 16784 KB | Output is correct |
32 | Correct | 0 ms | 16784 KB | Output is correct |
33 | Correct | 0 ms | 16784 KB | Output is correct |
34 | Correct | 0 ms | 16784 KB | Output is correct |
35 | Correct | 3 ms | 16784 KB | Output is correct |
36 | Correct | 0 ms | 16784 KB | Output is correct |
37 | Correct | 3 ms | 16784 KB | Output is correct |
38 | Correct | 3 ms | 16784 KB | Output is correct |
39 | Correct | 3 ms | 16784 KB | Output is correct |
40 | Correct | 3 ms | 16784 KB | Output is correct |
41 | Correct | 3 ms | 16784 KB | Output is correct |
42 | Correct | 3 ms | 16784 KB | Output is correct |
43 | Correct | 0 ms | 16784 KB | Output is correct |
44 | Correct | 3 ms | 16784 KB | Output is correct |
45 | Correct | 0 ms | 16784 KB | Output is correct |
46 | Correct | 0 ms | 16784 KB | Output is correct |
47 | Correct | 0 ms | 16784 KB | Output is correct |
48 | Correct | 0 ms | 16784 KB | Output is correct |
49 | Correct | 0 ms | 16784 KB | Output is correct |
50 | Correct | 0 ms | 16784 KB | Output is correct |
51 | Correct | 0 ms | 16784 KB | Output is correct |
52 | Correct | 0 ms | 16784 KB | Output is correct |
53 | Correct | 0 ms | 16784 KB | Output is correct |
54 | Correct | 3 ms | 16784 KB | Output is correct |
55 | Correct | 13 ms | 17048 KB | Output is correct |
56 | Correct | 6 ms | 17048 KB | Output is correct |
57 | Correct | 6 ms | 17048 KB | Output is correct |
58 | Correct | 6 ms | 17048 KB | Output is correct |
59 | Correct | 3 ms | 17048 KB | Output is correct |
60 | Correct | 6 ms | 17048 KB | Output is correct |
61 | Correct | 0 ms | 17048 KB | Output is correct |
62 | Correct | 3 ms | 16916 KB | Output is correct |
63 | Correct | 0 ms | 16784 KB | Output is correct |
64 | Correct | 6 ms | 17048 KB | Output is correct |
65 | Correct | 9 ms | 17048 KB | Output is correct |
66 | Correct | 6 ms | 17048 KB | Output is correct |
67 | Correct | 6 ms | 16916 KB | Output is correct |
68 | Correct | 6 ms | 16916 KB | Output is correct |
69 | Correct | 6 ms | 16916 KB | Output is correct |
70 | Correct | 6 ms | 17048 KB | Output is correct |
71 | Correct | 179 ms | 21536 KB | Output is correct |
72 | Correct | 126 ms | 22988 KB | Output is correct |
73 | Correct | 169 ms | 21536 KB | Output is correct |
74 | Correct | 116 ms | 22988 KB | Output is correct |
75 | Correct | 163 ms | 21536 KB | Output is correct |
76 | Correct | 146 ms | 21536 KB | Output is correct |
77 | Correct | 63 ms | 18764 KB | Output is correct |
78 | Correct | 176 ms | 21536 KB | Output is correct |
79 | Correct | 153 ms | 21536 KB | Output is correct |
80 | Correct | 143 ms | 22988 KB | Output is correct |
81 | Correct | 33 ms | 17708 KB | Output is correct |
82 | Correct | 116 ms | 20084 KB | Output is correct |
83 | Correct | 163 ms | 21536 KB | Output is correct |
84 | Correct | 183 ms | 21536 KB | Output is correct |
85 | Correct | 163 ms | 21536 KB | Output is correct |
86 | Correct | 156 ms | 21536 KB | Output is correct |
87 | Correct | 149 ms | 20352 KB | Output is correct |
88 | Correct | 29 ms | 17576 KB | Output is correct |
89 | Correct | 89 ms | 19556 KB | Output is correct |
90 | Correct | 63 ms | 19952 KB | Output is correct |
91 | Correct | 6 ms | 17048 KB | Output is correct |
92 | Correct | 59 ms | 19952 KB | Output is correct |