답안 #434663

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
434663 2021-06-21T14:11:13 Z Trunkty 꿈 (IOI13_dreaming) C++14
47 / 100
216 ms 34572 KB
#include "dreaming.h"
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
using namespace std;

vector<vector<int>> pairs[100005];
bool check[100005];
int mini,diam;
int dp[100005][3];
priority_queue<int> nums;

int dfs(int par, int a, int curr){
    check[a] = true;
    for(vector<int> i:pairs[a]){
        if(i[0]!=par){
            int x = dfs(a,i[0],i[1]);
            if(x>dp[a][1]){
                dp[a][2] = dp[a][1];
                dp[a][1] = x;
            }
            else if(x>dp[a][2]){
                dp[a][2] = x;
            }
        }
    }
    return dp[a][1]+curr;
}

void dfs2(int par, int a, int curr){
    if(curr>dp[a][1]){
        dp[a][2] = dp[a][1];
        dp[a][1] = curr;
    }
    else if(curr>dp[a][2]){
        dp[a][2] = curr;
    }
    for(vector<int> i:pairs[a]){
        if(i[0]!=par){
            if(dp[i[0]][1]+i[1]==dp[a][1]){
                dfs2(a,i[0],dp[a][2]+i[1]);
            }
            else{
                dfs2(a,i[0],dp[a][1]+i[1]);
            }
        }
    }
    mini = min(mini,dp[a][1]);
    diam = max(diam,dp[a][1]+dp[a][2]);
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    for(int i=0;i<M;i++){
        pairs[A[i]].push_back({B[i],T[i]});
        pairs[B[i]].push_back({A[i],T[i]});
    }
    for(int i=0;i<N;i++){
        if(!check[i]){
            mini = 1e9;
            dfs(-1,i,0);
            dfs2(-1,i,0);
            nums.push(mini);
        }
    }
    int a = nums.top();
    nums.pop();
    int b = nums.top();
    return max(a+b+L,diam);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 24132 KB Output is correct
2 Correct 105 ms 24792 KB Output is correct
3 Correct 83 ms 20512 KB Output is correct
4 Correct 14 ms 5964 KB Output is correct
5 Correct 11 ms 4684 KB Output is correct
6 Correct 24 ms 7628 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 55 ms 12100 KB Output is correct
9 Correct 79 ms 16804 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 126 ms 19520 KB Output is correct
12 Correct 151 ms 22156 KB Output is correct
13 Correct 3 ms 2764 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2660 KB Output is correct
5 Correct 3 ms 2636 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2656 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 3 ms 2636 KB Output is correct
14 Correct 2 ms 2656 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2680 KB Output is correct
20 Correct 2 ms 2672 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 3 ms 2636 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 24132 KB Output is correct
2 Correct 105 ms 24792 KB Output is correct
3 Correct 83 ms 20512 KB Output is correct
4 Correct 14 ms 5964 KB Output is correct
5 Correct 11 ms 4684 KB Output is correct
6 Correct 24 ms 7628 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 55 ms 12100 KB Output is correct
9 Correct 79 ms 16804 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 126 ms 19520 KB Output is correct
12 Correct 151 ms 22156 KB Output is correct
13 Correct 3 ms 2764 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2660 KB Output is correct
18 Correct 3 ms 2636 KB Output is correct
19 Correct 2 ms 2660 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2656 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 3 ms 2636 KB Output is correct
27 Correct 2 ms 2656 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 2636 KB Output is correct
31 Correct 2 ms 2636 KB Output is correct
32 Correct 2 ms 2680 KB Output is correct
33 Correct 2 ms 2672 KB Output is correct
34 Correct 2 ms 2636 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 2 ms 2636 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 3 ms 2636 KB Output is correct
39 Correct 122 ms 25348 KB Output is correct
40 Correct 137 ms 24740 KB Output is correct
41 Correct 67 ms 20476 KB Output is correct
42 Correct 13 ms 5964 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2636 KB Output is correct
47 Correct 2 ms 2636 KB Output is correct
48 Correct 2 ms 2636 KB Output is correct
49 Correct 2 ms 2636 KB Output is correct
50 Correct 2 ms 2656 KB Output is correct
51 Correct 3 ms 2636 KB Output is correct
52 Correct 2 ms 2636 KB Output is correct
53 Correct 2 ms 2668 KB Output is correct
54 Correct 2 ms 2636 KB Output is correct
55 Correct 2 ms 2636 KB Output is correct
56 Correct 2 ms 2636 KB Output is correct
57 Correct 162 ms 19440 KB Output is correct
58 Correct 166 ms 19428 KB Output is correct
59 Correct 187 ms 19404 KB Output is correct
60 Correct 176 ms 19460 KB Output is correct
61 Correct 185 ms 19420 KB Output is correct
62 Correct 207 ms 19400 KB Output is correct
63 Correct 163 ms 19176 KB Output is correct
64 Correct 163 ms 19216 KB Output is correct
65 Correct 183 ms 19552 KB Output is correct
66 Correct 190 ms 19484 KB Output is correct
67 Correct 197 ms 19468 KB Output is correct
68 Correct 168 ms 19392 KB Output is correct
69 Correct 173 ms 19728 KB Output is correct
70 Correct 176 ms 19652 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 5 ms 3148 KB Output is correct
73 Correct 4 ms 3148 KB Output is correct
74 Correct 6 ms 3148 KB Output is correct
75 Correct 5 ms 3148 KB Output is correct
76 Correct 5 ms 3180 KB Output is correct
77 Correct 5 ms 3148 KB Output is correct
78 Correct 5 ms 3148 KB Output is correct
79 Correct 5 ms 3184 KB Output is correct
80 Correct 179 ms 19368 KB Output is correct
81 Correct 175 ms 19428 KB Output is correct
82 Correct 168 ms 19420 KB Output is correct
83 Correct 198 ms 19524 KB Output is correct
84 Correct 4 ms 3060 KB Output is correct
85 Correct 4 ms 2932 KB Output is correct
86 Correct 4 ms 3060 KB Output is correct
87 Correct 4 ms 3020 KB Output is correct
88 Correct 4 ms 3020 KB Output is correct
89 Correct 4 ms 3020 KB Output is correct
90 Correct 5 ms 3020 KB Output is correct
91 Correct 4 ms 3148 KB Output is correct
92 Correct 4 ms 3020 KB Output is correct
93 Correct 5 ms 3020 KB Output is correct
94 Correct 3 ms 2656 KB Output is correct
95 Correct 2 ms 2636 KB Output is correct
96 Correct 2 ms 2636 KB Output is correct
97 Correct 2 ms 2636 KB Output is correct
98 Correct 3 ms 2636 KB Output is correct
99 Correct 2 ms 2636 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2636 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 11 ms 4632 KB Output is correct
105 Correct 23 ms 7696 KB Output is correct
106 Correct 2 ms 2656 KB Output is correct
107 Correct 53 ms 12100 KB Output is correct
108 Correct 74 ms 16836 KB Output is correct
109 Correct 2 ms 2764 KB Output is correct
110 Correct 121 ms 19396 KB Output is correct
111 Correct 153 ms 22144 KB Output is correct
112 Correct 3 ms 2800 KB Output is correct
113 Correct 216 ms 34572 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 32 ms 8456 KB Output is correct
2 Incorrect 33 ms 8464 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2660 KB Output is correct
5 Correct 3 ms 2636 KB Output is correct
6 Correct 2 ms 2660 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 2 ms 2636 KB Output is correct
10 Correct 2 ms 2656 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 2 ms 2636 KB Output is correct
13 Correct 3 ms 2636 KB Output is correct
14 Correct 2 ms 2656 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2636 KB Output is correct
18 Correct 2 ms 2636 KB Output is correct
19 Correct 2 ms 2680 KB Output is correct
20 Correct 2 ms 2672 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 3 ms 2636 KB Output is correct
26 Correct 3 ms 2792 KB Output is correct
27 Correct 3 ms 2924 KB Output is correct
28 Correct 5 ms 3096 KB Output is correct
29 Correct 3 ms 2764 KB Output is correct
30 Correct 3 ms 2892 KB Output is correct
31 Correct 4 ms 3052 KB Output is correct
32 Incorrect 3 ms 2792 KB Output isn't correct
33 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 105 ms 24132 KB Output is correct
2 Correct 105 ms 24792 KB Output is correct
3 Correct 83 ms 20512 KB Output is correct
4 Correct 14 ms 5964 KB Output is correct
5 Correct 11 ms 4684 KB Output is correct
6 Correct 24 ms 7628 KB Output is correct
7 Correct 2 ms 2636 KB Output is correct
8 Correct 55 ms 12100 KB Output is correct
9 Correct 79 ms 16804 KB Output is correct
10 Correct 3 ms 2764 KB Output is correct
11 Correct 126 ms 19520 KB Output is correct
12 Correct 151 ms 22156 KB Output is correct
13 Correct 3 ms 2764 KB Output is correct
14 Correct 2 ms 2636 KB Output is correct
15 Correct 2 ms 2636 KB Output is correct
16 Correct 2 ms 2636 KB Output is correct
17 Correct 2 ms 2660 KB Output is correct
18 Correct 3 ms 2636 KB Output is correct
19 Correct 2 ms 2660 KB Output is correct
20 Correct 2 ms 2636 KB Output is correct
21 Correct 2 ms 2636 KB Output is correct
22 Correct 2 ms 2636 KB Output is correct
23 Correct 2 ms 2656 KB Output is correct
24 Correct 2 ms 2636 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 3 ms 2636 KB Output is correct
27 Correct 2 ms 2656 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 2636 KB Output is correct
31 Correct 2 ms 2636 KB Output is correct
32 Correct 2 ms 2680 KB Output is correct
33 Correct 2 ms 2672 KB Output is correct
34 Correct 2 ms 2636 KB Output is correct
35 Correct 2 ms 2652 KB Output is correct
36 Correct 2 ms 2636 KB Output is correct
37 Correct 2 ms 2636 KB Output is correct
38 Correct 3 ms 2636 KB Output is correct
39 Correct 122 ms 25348 KB Output is correct
40 Correct 137 ms 24740 KB Output is correct
41 Correct 67 ms 20476 KB Output is correct
42 Correct 13 ms 5964 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 2 ms 2636 KB Output is correct
46 Correct 2 ms 2636 KB Output is correct
47 Correct 2 ms 2636 KB Output is correct
48 Correct 2 ms 2636 KB Output is correct
49 Correct 2 ms 2636 KB Output is correct
50 Correct 2 ms 2656 KB Output is correct
51 Correct 3 ms 2636 KB Output is correct
52 Correct 2 ms 2636 KB Output is correct
53 Correct 2 ms 2668 KB Output is correct
54 Correct 2 ms 2636 KB Output is correct
55 Correct 2 ms 2636 KB Output is correct
56 Correct 2 ms 2636 KB Output is correct
57 Correct 162 ms 19440 KB Output is correct
58 Correct 166 ms 19428 KB Output is correct
59 Correct 187 ms 19404 KB Output is correct
60 Correct 176 ms 19460 KB Output is correct
61 Correct 185 ms 19420 KB Output is correct
62 Correct 207 ms 19400 KB Output is correct
63 Correct 163 ms 19176 KB Output is correct
64 Correct 163 ms 19216 KB Output is correct
65 Correct 183 ms 19552 KB Output is correct
66 Correct 190 ms 19484 KB Output is correct
67 Correct 197 ms 19468 KB Output is correct
68 Correct 168 ms 19392 KB Output is correct
69 Correct 173 ms 19728 KB Output is correct
70 Correct 176 ms 19652 KB Output is correct
71 Correct 2 ms 2636 KB Output is correct
72 Correct 5 ms 3148 KB Output is correct
73 Correct 4 ms 3148 KB Output is correct
74 Correct 6 ms 3148 KB Output is correct
75 Correct 5 ms 3148 KB Output is correct
76 Correct 5 ms 3180 KB Output is correct
77 Correct 5 ms 3148 KB Output is correct
78 Correct 5 ms 3148 KB Output is correct
79 Correct 5 ms 3184 KB Output is correct
80 Correct 179 ms 19368 KB Output is correct
81 Correct 175 ms 19428 KB Output is correct
82 Correct 168 ms 19420 KB Output is correct
83 Correct 198 ms 19524 KB Output is correct
84 Correct 4 ms 3060 KB Output is correct
85 Correct 4 ms 2932 KB Output is correct
86 Correct 4 ms 3060 KB Output is correct
87 Correct 4 ms 3020 KB Output is correct
88 Correct 4 ms 3020 KB Output is correct
89 Correct 4 ms 3020 KB Output is correct
90 Correct 5 ms 3020 KB Output is correct
91 Correct 4 ms 3148 KB Output is correct
92 Correct 4 ms 3020 KB Output is correct
93 Correct 5 ms 3020 KB Output is correct
94 Correct 3 ms 2656 KB Output is correct
95 Correct 2 ms 2636 KB Output is correct
96 Correct 2 ms 2636 KB Output is correct
97 Correct 2 ms 2636 KB Output is correct
98 Correct 3 ms 2636 KB Output is correct
99 Correct 2 ms 2636 KB Output is correct
100 Correct 2 ms 2636 KB Output is correct
101 Correct 2 ms 2636 KB Output is correct
102 Correct 2 ms 2636 KB Output is correct
103 Correct 2 ms 2636 KB Output is correct
104 Correct 11 ms 4632 KB Output is correct
105 Correct 23 ms 7696 KB Output is correct
106 Correct 2 ms 2656 KB Output is correct
107 Correct 53 ms 12100 KB Output is correct
108 Correct 74 ms 16836 KB Output is correct
109 Correct 2 ms 2764 KB Output is correct
110 Correct 121 ms 19396 KB Output is correct
111 Correct 153 ms 22144 KB Output is correct
112 Correct 3 ms 2800 KB Output is correct
113 Correct 216 ms 34572 KB Output is correct
114 Correct 32 ms 8456 KB Output is correct
115 Incorrect 33 ms 8464 KB Output isn't correct
116 Halted 0 ms 0 KB -