# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
242259 | 2020-06-27T07:44:47 Z | shenxy | Magic Tree (CEOI19_magictree) | C++11 | 118 ms | 32376 KB |
#include <cstdio> #include <algorithm> #include <vector> #include <cstring> using namespace std; int n, m, k, d[100000]; long long dpt1[100000][22], w[100000]; vector<int> adjlist[100000]; long long dp1(int v, int x) { if (dpt1[v][x] != -1) return dpt1[v][x]; if (x == 0) return dpt1[v][x] = 0; dpt1[v][x] = (d[v] == x ? w[v] : 0); for (int i: adjlist[v]) dpt1[v][x] += dp1(i, x); return dpt1[v][x] = max(dpt1[v][x], dp1(v, x - 1)); } int main() { scanf("%d %d %d", &n, &m, &k); if (k <= 20) { int p, v, D, W; for (int i = 1; i < n; ++i) { scanf("%d", &p); adjlist[p - 1].push_back(i); } fill_n(d, 100000, 0); fill_n(w, 100000, 0); for (int i = 0; i < m; ++i) { scanf("%d %d %d", &v, &D, &W); d[v - 1] = D; w[v - 1] = W; } memset(dpt1, -1, sizeof dpt1); printf("%lld", dp1(0, k + 1)); } else { for (int i = 1; i < n; ++i) scanf("%d", &k); int v, d, w; long long ans = 0; for (int i = 0; i < m; ++i) { scanf("%d %d %d", &v, &d, &w); ans += w; } printf("%lld", ans); } return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 20992 KB | Output is correct |
2 | Correct | 14 ms | 20992 KB | Output is correct |
3 | Correct | 19 ms | 20992 KB | Output is correct |
4 | Correct | 15 ms | 20992 KB | Output is correct |
5 | Correct | 15 ms | 21120 KB | Output is correct |
6 | Correct | 14 ms | 20992 KB | Output is correct |
7 | Correct | 15 ms | 20992 KB | Output is correct |
8 | Correct | 14 ms | 20992 KB | Output is correct |
9 | Correct | 15 ms | 20992 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 30 ms | 2688 KB | Output is correct |
2 | Correct | 25 ms | 2688 KB | Output is correct |
3 | Correct | 62 ms | 2688 KB | Output is correct |
4 | Correct | 53 ms | 2688 KB | Output is correct |
5 | Correct | 54 ms | 2688 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 94 ms | 22648 KB | Output is correct |
2 | Correct | 97 ms | 23032 KB | Output is correct |
3 | Correct | 87 ms | 27128 KB | Output is correct |
4 | Correct | 64 ms | 22000 KB | Output is correct |
5 | Correct | 77 ms | 32376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 20992 KB | Output is correct |
2 | Correct | 14 ms | 20992 KB | Output is correct |
3 | Correct | 19 ms | 20992 KB | Output is correct |
4 | Correct | 15 ms | 20992 KB | Output is correct |
5 | Correct | 15 ms | 21120 KB | Output is correct |
6 | Correct | 14 ms | 20992 KB | Output is correct |
7 | Correct | 15 ms | 20992 KB | Output is correct |
8 | Correct | 14 ms | 20992 KB | Output is correct |
9 | Correct | 15 ms | 20992 KB | Output is correct |
10 | Correct | 118 ms | 23032 KB | Output is correct |
11 | Correct | 103 ms | 23032 KB | Output is correct |
12 | Correct | 106 ms | 27128 KB | Output is correct |
13 | Correct | 99 ms | 22000 KB | Output is correct |
14 | Correct | 92 ms | 32376 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Incorrect | 9 ms | 2688 KB | Output isn't correct |
2 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 20992 KB | Output is correct |
2 | Correct | 14 ms | 20992 KB | Output is correct |
3 | Correct | 19 ms | 20992 KB | Output is correct |
4 | Correct | 15 ms | 20992 KB | Output is correct |
5 | Correct | 15 ms | 21120 KB | Output is correct |
6 | Correct | 14 ms | 20992 KB | Output is correct |
7 | Correct | 15 ms | 20992 KB | Output is correct |
8 | Correct | 14 ms | 20992 KB | Output is correct |
9 | Correct | 15 ms | 20992 KB | Output is correct |
10 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
11 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 14 ms | 20992 KB | Output is correct |
2 | Correct | 14 ms | 20992 KB | Output is correct |
3 | Correct | 19 ms | 20992 KB | Output is correct |
4 | Correct | 15 ms | 20992 KB | Output is correct |
5 | Correct | 15 ms | 21120 KB | Output is correct |
6 | Correct | 14 ms | 20992 KB | Output is correct |
7 | Correct | 15 ms | 20992 KB | Output is correct |
8 | Correct | 14 ms | 20992 KB | Output is correct |
9 | Correct | 15 ms | 20992 KB | Output is correct |
10 | Correct | 30 ms | 2688 KB | Output is correct |
11 | Correct | 25 ms | 2688 KB | Output is correct |
12 | Correct | 62 ms | 2688 KB | Output is correct |
13 | Correct | 53 ms | 2688 KB | Output is correct |
14 | Correct | 54 ms | 2688 KB | Output is correct |
15 | Incorrect | 6 ms | 2688 KB | Output isn't correct |
16 | Halted | 0 ms | 0 KB | - |