답안 #830949

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
830949 2023-08-19T13:30:59 Z Kerim 꿈 (IOI13_dreaming) C++17
47 / 100
73 ms 14156 KB
#include "dreaming.h"
#include "bits/stdc++.h"
using namespace std;
typedef pair<int, int> pii;
const int N = 1e5+5;
vector<pii> adj[N];
vector<int> members;
bool vis[N];

void dfs0(int nd, int pr){
    vis[nd] = 1;
    members.push_back(nd);
    for (auto [to, w]: adj[nd])
        if (to != pr)
            dfs0(to, nd);
}
int max_weight, endpoint, dp[N];
void dfs(int nd, int pr, int weight){
    if (weight > max_weight){
        max_weight = weight;
        endpoint = nd;
    }
    dp[nd] = max(dp[nd], weight);
    for (auto [to, w]: adj[nd])
        if (to != pr)
            dfs(to, nd, weight+w);
}

int travelTime(int n, int m, int L, int A[], int B[], int T[]) {
    for (int i = 0; i < m; i++){
        int u = A[i], v = B[i], w = T[i];
        adj[u].push_back({v, w});
        adj[v].push_back({u, w});
    }
    vector<int> roots;
    for (int i = 0; i < n; i++)
        if (!vis[i]){
            dfs0(i, -1);
            roots.push_back(i);
        }
    assert(roots.size() == 2);
    vector<int> d;
    int sum = L;
    for (auto root: roots){
        members.clear();
        dfs0(root, -1);

        max_weight = 0;
        dfs(root, -1, 0);
        int a = endpoint; 
        max_weight = 0;
        dfs(endpoint, -1, 0);
        int b = endpoint;
        d.push_back(max_weight);
        dfs(a, -1, 0);
        dfs(b, -1, 0);

        int value = INT_MAX;
        for (auto member: members)
            if (value > dp[member])
                value = dp[member];
        sum += value;
    }
    return max(sum, max(d[0], d[1]));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 11732 KB Output is correct
2 Correct 38 ms 11768 KB Output is correct
3 Correct 25 ms 8680 KB Output is correct
4 Correct 6 ms 4052 KB Output is correct
5 Correct 6 ms 3412 KB Output is correct
6 Correct 11 ms 4740 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 21 ms 6504 KB Output is correct
9 Correct 29 ms 7912 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 57 ms 9744 KB Output is correct
12 Correct 64 ms 11228 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2656 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2656 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 1 ms 2644 KB Output is correct
20 Correct 1 ms 2656 KB Output is correct
21 Correct 1 ms 2656 KB Output is correct
22 Correct 1 ms 2656 KB Output is correct
23 Correct 2 ms 2656 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 11732 KB Output is correct
2 Correct 38 ms 11768 KB Output is correct
3 Correct 25 ms 8680 KB Output is correct
4 Correct 6 ms 4052 KB Output is correct
5 Correct 6 ms 3412 KB Output is correct
6 Correct 11 ms 4740 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 21 ms 6504 KB Output is correct
9 Correct 29 ms 7912 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 57 ms 9744 KB Output is correct
12 Correct 64 ms 11228 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2656 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
26 Correct 1 ms 2656 KB Output is correct
27 Correct 1 ms 2644 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 1 ms 2644 KB Output is correct
32 Correct 1 ms 2644 KB Output is correct
33 Correct 1 ms 2656 KB Output is correct
34 Correct 1 ms 2656 KB Output is correct
35 Correct 1 ms 2656 KB Output is correct
36 Correct 2 ms 2656 KB Output is correct
37 Correct 1 ms 2644 KB Output is correct
38 Correct 1 ms 2644 KB Output is correct
39 Correct 43 ms 13012 KB Output is correct
40 Correct 38 ms 12980 KB Output is correct
41 Correct 28 ms 9588 KB Output is correct
42 Correct 6 ms 4180 KB Output is correct
43 Correct 1 ms 2644 KB Output is correct
44 Correct 2 ms 2644 KB Output is correct
45 Correct 1 ms 2644 KB Output is correct
46 Correct 1 ms 2660 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 1 ms 2656 KB Output is correct
49 Correct 1 ms 2644 KB Output is correct
50 Correct 2 ms 2644 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 1 ms 2644 KB Output is correct
53 Correct 1 ms 2644 KB Output is correct
54 Correct 2 ms 2644 KB Output is correct
55 Correct 1 ms 2588 KB Output is correct
56 Correct 1 ms 2656 KB Output is correct
57 Correct 63 ms 10084 KB Output is correct
58 Correct 53 ms 10168 KB Output is correct
59 Correct 54 ms 9996 KB Output is correct
60 Correct 52 ms 10080 KB Output is correct
61 Correct 72 ms 10108 KB Output is correct
62 Correct 52 ms 10100 KB Output is correct
63 Correct 49 ms 9784 KB Output is correct
64 Correct 54 ms 9868 KB Output is correct
65 Correct 48 ms 10060 KB Output is correct
66 Correct 47 ms 10032 KB Output is correct
67 Correct 51 ms 9952 KB Output is correct
68 Correct 52 ms 10052 KB Output is correct
69 Correct 53 ms 10264 KB Output is correct
70 Correct 53 ms 10260 KB Output is correct
71 Correct 1 ms 2644 KB Output is correct
72 Correct 2 ms 2900 KB Output is correct
73 Correct 2 ms 2788 KB Output is correct
74 Correct 2 ms 2900 KB Output is correct
75 Correct 3 ms 2900 KB Output is correct
76 Correct 2 ms 2900 KB Output is correct
77 Correct 2 ms 2900 KB Output is correct
78 Correct 2 ms 2900 KB Output is correct
79 Correct 2 ms 2796 KB Output is correct
80 Correct 53 ms 9944 KB Output is correct
81 Correct 51 ms 9968 KB Output is correct
82 Correct 49 ms 10108 KB Output is correct
83 Correct 48 ms 10180 KB Output is correct
84 Correct 2 ms 2772 KB Output is correct
85 Correct 2 ms 2792 KB Output is correct
86 Correct 3 ms 2900 KB Output is correct
87 Correct 2 ms 2772 KB Output is correct
88 Correct 2 ms 2772 KB Output is correct
89 Correct 2 ms 2772 KB Output is correct
90 Correct 2 ms 2772 KB Output is correct
91 Correct 2 ms 2796 KB Output is correct
92 Correct 2 ms 2800 KB Output is correct
93 Correct 2 ms 2772 KB Output is correct
94 Correct 1 ms 2656 KB Output is correct
95 Correct 2 ms 2644 KB Output is correct
96 Correct 1 ms 2644 KB Output is correct
97 Correct 1 ms 2644 KB Output is correct
98 Correct 1 ms 2644 KB Output is correct
99 Correct 1 ms 2644 KB Output is correct
100 Correct 2 ms 2644 KB Output is correct
101 Correct 1 ms 2644 KB Output is correct
102 Correct 1 ms 2644 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 6 ms 3540 KB Output is correct
105 Correct 11 ms 5076 KB Output is correct
106 Correct 2 ms 2660 KB Output is correct
107 Correct 21 ms 6504 KB Output is correct
108 Correct 30 ms 7836 KB Output is correct
109 Correct 1 ms 2660 KB Output is correct
110 Correct 38 ms 9684 KB Output is correct
111 Correct 44 ms 11248 KB Output is correct
112 Correct 2 ms 2644 KB Output is correct
113 Correct 73 ms 14156 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Runtime error 15 ms 11724 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2644 KB Output is correct
2 Correct 1 ms 2644 KB Output is correct
3 Correct 1 ms 2644 KB Output is correct
4 Correct 1 ms 2656 KB Output is correct
5 Correct 1 ms 2644 KB Output is correct
6 Correct 2 ms 2644 KB Output is correct
7 Correct 1 ms 2644 KB Output is correct
8 Correct 1 ms 2644 KB Output is correct
9 Correct 1 ms 2644 KB Output is correct
10 Correct 1 ms 2644 KB Output is correct
11 Correct 1 ms 2644 KB Output is correct
12 Correct 1 ms 2644 KB Output is correct
13 Correct 1 ms 2656 KB Output is correct
14 Correct 1 ms 2644 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2644 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 1 ms 2644 KB Output is correct
20 Correct 1 ms 2656 KB Output is correct
21 Correct 1 ms 2656 KB Output is correct
22 Correct 1 ms 2656 KB Output is correct
23 Correct 2 ms 2656 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
26 Runtime error 3 ms 5332 KB Execution killed with signal 6
27 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 37 ms 11732 KB Output is correct
2 Correct 38 ms 11768 KB Output is correct
3 Correct 25 ms 8680 KB Output is correct
4 Correct 6 ms 4052 KB Output is correct
5 Correct 6 ms 3412 KB Output is correct
6 Correct 11 ms 4740 KB Output is correct
7 Correct 2 ms 2644 KB Output is correct
8 Correct 21 ms 6504 KB Output is correct
9 Correct 29 ms 7912 KB Output is correct
10 Correct 2 ms 2644 KB Output is correct
11 Correct 57 ms 9744 KB Output is correct
12 Correct 64 ms 11228 KB Output is correct
13 Correct 2 ms 2644 KB Output is correct
14 Correct 2 ms 2644 KB Output is correct
15 Correct 1 ms 2644 KB Output is correct
16 Correct 1 ms 2644 KB Output is correct
17 Correct 1 ms 2656 KB Output is correct
18 Correct 1 ms 2644 KB Output is correct
19 Correct 2 ms 2644 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 1 ms 2644 KB Output is correct
23 Correct 1 ms 2644 KB Output is correct
24 Correct 1 ms 2644 KB Output is correct
25 Correct 1 ms 2644 KB Output is correct
26 Correct 1 ms 2656 KB Output is correct
27 Correct 1 ms 2644 KB Output is correct
28 Correct 2 ms 2652 KB Output is correct
29 Correct 2 ms 2644 KB Output is correct
30 Correct 2 ms 2652 KB Output is correct
31 Correct 1 ms 2644 KB Output is correct
32 Correct 1 ms 2644 KB Output is correct
33 Correct 1 ms 2656 KB Output is correct
34 Correct 1 ms 2656 KB Output is correct
35 Correct 1 ms 2656 KB Output is correct
36 Correct 2 ms 2656 KB Output is correct
37 Correct 1 ms 2644 KB Output is correct
38 Correct 1 ms 2644 KB Output is correct
39 Correct 43 ms 13012 KB Output is correct
40 Correct 38 ms 12980 KB Output is correct
41 Correct 28 ms 9588 KB Output is correct
42 Correct 6 ms 4180 KB Output is correct
43 Correct 1 ms 2644 KB Output is correct
44 Correct 2 ms 2644 KB Output is correct
45 Correct 1 ms 2644 KB Output is correct
46 Correct 1 ms 2660 KB Output is correct
47 Correct 1 ms 2644 KB Output is correct
48 Correct 1 ms 2656 KB Output is correct
49 Correct 1 ms 2644 KB Output is correct
50 Correct 2 ms 2644 KB Output is correct
51 Correct 2 ms 2644 KB Output is correct
52 Correct 1 ms 2644 KB Output is correct
53 Correct 1 ms 2644 KB Output is correct
54 Correct 2 ms 2644 KB Output is correct
55 Correct 1 ms 2588 KB Output is correct
56 Correct 1 ms 2656 KB Output is correct
57 Correct 63 ms 10084 KB Output is correct
58 Correct 53 ms 10168 KB Output is correct
59 Correct 54 ms 9996 KB Output is correct
60 Correct 52 ms 10080 KB Output is correct
61 Correct 72 ms 10108 KB Output is correct
62 Correct 52 ms 10100 KB Output is correct
63 Correct 49 ms 9784 KB Output is correct
64 Correct 54 ms 9868 KB Output is correct
65 Correct 48 ms 10060 KB Output is correct
66 Correct 47 ms 10032 KB Output is correct
67 Correct 51 ms 9952 KB Output is correct
68 Correct 52 ms 10052 KB Output is correct
69 Correct 53 ms 10264 KB Output is correct
70 Correct 53 ms 10260 KB Output is correct
71 Correct 1 ms 2644 KB Output is correct
72 Correct 2 ms 2900 KB Output is correct
73 Correct 2 ms 2788 KB Output is correct
74 Correct 2 ms 2900 KB Output is correct
75 Correct 3 ms 2900 KB Output is correct
76 Correct 2 ms 2900 KB Output is correct
77 Correct 2 ms 2900 KB Output is correct
78 Correct 2 ms 2900 KB Output is correct
79 Correct 2 ms 2796 KB Output is correct
80 Correct 53 ms 9944 KB Output is correct
81 Correct 51 ms 9968 KB Output is correct
82 Correct 49 ms 10108 KB Output is correct
83 Correct 48 ms 10180 KB Output is correct
84 Correct 2 ms 2772 KB Output is correct
85 Correct 2 ms 2792 KB Output is correct
86 Correct 3 ms 2900 KB Output is correct
87 Correct 2 ms 2772 KB Output is correct
88 Correct 2 ms 2772 KB Output is correct
89 Correct 2 ms 2772 KB Output is correct
90 Correct 2 ms 2772 KB Output is correct
91 Correct 2 ms 2796 KB Output is correct
92 Correct 2 ms 2800 KB Output is correct
93 Correct 2 ms 2772 KB Output is correct
94 Correct 1 ms 2656 KB Output is correct
95 Correct 2 ms 2644 KB Output is correct
96 Correct 1 ms 2644 KB Output is correct
97 Correct 1 ms 2644 KB Output is correct
98 Correct 1 ms 2644 KB Output is correct
99 Correct 1 ms 2644 KB Output is correct
100 Correct 2 ms 2644 KB Output is correct
101 Correct 1 ms 2644 KB Output is correct
102 Correct 1 ms 2644 KB Output is correct
103 Correct 2 ms 2644 KB Output is correct
104 Correct 6 ms 3540 KB Output is correct
105 Correct 11 ms 5076 KB Output is correct
106 Correct 2 ms 2660 KB Output is correct
107 Correct 21 ms 6504 KB Output is correct
108 Correct 30 ms 7836 KB Output is correct
109 Correct 1 ms 2660 KB Output is correct
110 Correct 38 ms 9684 KB Output is correct
111 Correct 44 ms 11248 KB Output is correct
112 Correct 2 ms 2644 KB Output is correct
113 Correct 73 ms 14156 KB Output is correct
114 Runtime error 15 ms 11724 KB Execution killed with signal 6
115 Halted 0 ms 0 KB -