답안 #153813

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
153813 2019-09-16T14:30:18 Z popovicirobert 꿈 (IOI13_dreaming) C++14
47 / 100
169 ms 14964 KB
#include "dreaming.h"
#include <bits/stdc++.h>

using namespace std;

const int INF = 2e9;
const int MAXN = (int) 1e5;

static vector < pair <int, int> > g[MAXN + 1];
static int dstA[MAXN + 1], dstB[MAXN + 1];
static bool vis[MAXN + 1], on_way[MAXN + 1];
static vector <int> nodes;

void dfs(int nod, int par, int *dst) {
    if(vis[nod] == 0) {
        nodes.push_back(nod);
    }
    vis[nod] = 1;
    for(auto it : g[nod]) {
        if(it.first != par) {
            dst[it.first] = dst[nod] + it.second;
            dfs(it.first, nod, dst);
        }
    }
}

int travelTime(int n, int m, int l, int A[], int B[], int T[]) {
    int i;
    for(i = 0; i < m; i++) {
        A[i]++, B[i]++;
        g[A[i]].push_back({B[i], T[i]});
        g[B[i]].push_back({A[i], T[i]});
    }

    vector <int> dst;
    int ans = 0;
    for(i = 1; i <= n; i++) {
        if(vis[i]) continue;

        nodes.clear();
        dfs(i, 0, dstA);
        int a = 0;
        for(auto it : nodes) {
            if(dstA[it] >= dstA[a]) {
                a = it;
            }
        }
        dstA[a] = 0;
        dfs(a, 0, dstA);

        int b = 0;
        for(auto it : nodes) {
            if(dstA[it] >= dstA[b]) {
                b = it;
            }
        }
        dfs(b, 0, dstB);
        ans = max(ans, dstA[b]);

        int cur_dst = INF;
        for(auto it : nodes) {
            if(cur_dst >= max(dstA[it], dstB[it])) {
                cur_dst = max(dstA[it], dstB[it]);
            }
        }
        dst.push_back(cur_dst);
    }
    sort(dst.rbegin(), dst.rend());
    if(dst.size() > 1) {
        ans = max(ans, dst[0] + dst[1] + l);
    }
    return ans;
}

Compilation message

dreaming.cpp:11:28: warning: 'on_way' defined but not used [-Wunused-variable]
 static bool vis[MAXN + 1], on_way[MAXN + 1];
                            ^~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 14964 KB Output is correct
2 Correct 80 ms 14836 KB Output is correct
3 Correct 49 ms 10868 KB Output is correct
4 Correct 15 ms 4600 KB Output is correct
5 Correct 14 ms 3704 KB Output is correct
6 Correct 26 ms 5496 KB Output is correct
7 Correct 5 ms 2680 KB Output is correct
8 Correct 44 ms 7032 KB Output is correct
9 Correct 62 ms 8824 KB Output is correct
10 Correct 5 ms 2804 KB Output is correct
11 Correct 110 ms 10872 KB Output is correct
12 Correct 98 ms 12652 KB Output is correct
13 Correct 6 ms 2808 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 14964 KB Output is correct
2 Correct 80 ms 14836 KB Output is correct
3 Correct 49 ms 10868 KB Output is correct
4 Correct 15 ms 4600 KB Output is correct
5 Correct 14 ms 3704 KB Output is correct
6 Correct 26 ms 5496 KB Output is correct
7 Correct 5 ms 2680 KB Output is correct
8 Correct 44 ms 7032 KB Output is correct
9 Correct 62 ms 8824 KB Output is correct
10 Correct 5 ms 2804 KB Output is correct
11 Correct 110 ms 10872 KB Output is correct
12 Correct 98 ms 12652 KB Output is correct
13 Correct 6 ms 2808 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 5 ms 2680 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 5 ms 2680 KB Output is correct
18 Correct 5 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 5 ms 2680 KB Output is correct
22 Correct 7 ms 2680 KB Output is correct
23 Correct 5 ms 2680 KB Output is correct
24 Correct 5 ms 2680 KB Output is correct
25 Correct 5 ms 2680 KB Output is correct
26 Correct 4 ms 2680 KB Output is correct
27 Correct 4 ms 2680 KB Output is correct
28 Correct 4 ms 2680 KB Output is correct
29 Correct 4 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 5 ms 2680 KB Output is correct
32 Correct 4 ms 2680 KB Output is correct
33 Correct 5 ms 2680 KB Output is correct
34 Correct 5 ms 2680 KB Output is correct
35 Correct 4 ms 2680 KB Output is correct
36 Correct 5 ms 2680 KB Output is correct
37 Correct 5 ms 2684 KB Output is correct
38 Correct 4 ms 2680 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 14964 KB Output is correct
2 Correct 80 ms 14836 KB Output is correct
3 Correct 49 ms 10868 KB Output is correct
4 Correct 15 ms 4600 KB Output is correct
5 Correct 14 ms 3704 KB Output is correct
6 Correct 26 ms 5496 KB Output is correct
7 Correct 5 ms 2680 KB Output is correct
8 Correct 44 ms 7032 KB Output is correct
9 Correct 62 ms 8824 KB Output is correct
10 Correct 5 ms 2804 KB Output is correct
11 Correct 110 ms 10872 KB Output is correct
12 Correct 98 ms 12652 KB Output is correct
13 Correct 6 ms 2808 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 5 ms 2680 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 5 ms 2680 KB Output is correct
18 Correct 5 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 5 ms 2680 KB Output is correct
22 Correct 7 ms 2680 KB Output is correct
23 Correct 5 ms 2680 KB Output is correct
24 Correct 5 ms 2680 KB Output is correct
25 Correct 5 ms 2680 KB Output is correct
26 Correct 4 ms 2680 KB Output is correct
27 Correct 4 ms 2680 KB Output is correct
28 Correct 4 ms 2680 KB Output is correct
29 Correct 4 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 5 ms 2680 KB Output is correct
32 Correct 4 ms 2680 KB Output is correct
33 Correct 5 ms 2680 KB Output is correct
34 Correct 5 ms 2680 KB Output is correct
35 Correct 4 ms 2680 KB Output is correct
36 Correct 5 ms 2680 KB Output is correct
37 Correct 5 ms 2684 KB Output is correct
38 Correct 4 ms 2680 KB Output is correct
39 Correct 78 ms 14840 KB Output is correct
40 Correct 74 ms 14836 KB Output is correct
41 Correct 49 ms 11000 KB Output is correct
42 Correct 14 ms 4600 KB Output is correct
43 Correct 4 ms 2680 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 4 ms 2680 KB Output is correct
47 Correct 4 ms 2680 KB Output is correct
48 Correct 5 ms 2680 KB Output is correct
49 Correct 4 ms 2680 KB Output is correct
50 Correct 4 ms 2680 KB Output is correct
51 Correct 4 ms 2680 KB Output is correct
52 Correct 4 ms 2680 KB Output is correct
53 Correct 5 ms 2680 KB Output is correct
54 Correct 4 ms 2680 KB Output is correct
55 Correct 5 ms 2680 KB Output is correct
56 Correct 4 ms 2680 KB Output is correct
57 Correct 105 ms 9196 KB Output is correct
58 Correct 115 ms 9076 KB Output is correct
59 Correct 169 ms 9072 KB Output is correct
60 Correct 157 ms 8920 KB Output is correct
61 Correct 107 ms 9048 KB Output is correct
62 Correct 101 ms 8952 KB Output is correct
63 Correct 100 ms 8880 KB Output is correct
64 Correct 133 ms 8944 KB Output is correct
65 Correct 110 ms 9000 KB Output is correct
66 Correct 134 ms 8920 KB Output is correct
67 Correct 161 ms 9156 KB Output is correct
68 Correct 140 ms 9168 KB Output is correct
69 Correct 106 ms 9076 KB Output is correct
70 Correct 115 ms 9076 KB Output is correct
71 Correct 4 ms 2680 KB Output is correct
72 Correct 7 ms 2924 KB Output is correct
73 Correct 6 ms 2936 KB Output is correct
74 Correct 6 ms 2936 KB Output is correct
75 Correct 6 ms 2936 KB Output is correct
76 Correct 6 ms 2936 KB Output is correct
77 Correct 6 ms 2936 KB Output is correct
78 Correct 6 ms 2940 KB Output is correct
79 Correct 6 ms 3064 KB Output is correct
80 Correct 101 ms 9332 KB Output is correct
81 Correct 97 ms 9068 KB Output is correct
82 Correct 104 ms 8948 KB Output is correct
83 Correct 108 ms 9104 KB Output is correct
84 Correct 5 ms 2808 KB Output is correct
85 Correct 5 ms 2808 KB Output is correct
86 Correct 6 ms 2808 KB Output is correct
87 Correct 6 ms 2864 KB Output is correct
88 Correct 5 ms 2936 KB Output is correct
89 Correct 6 ms 2808 KB Output is correct
90 Correct 6 ms 2808 KB Output is correct
91 Correct 6 ms 2808 KB Output is correct
92 Correct 6 ms 2808 KB Output is correct
93 Correct 6 ms 2808 KB Output is correct
94 Correct 5 ms 2680 KB Output is correct
95 Correct 5 ms 2680 KB Output is correct
96 Correct 5 ms 2680 KB Output is correct
97 Correct 4 ms 2680 KB Output is correct
98 Correct 4 ms 2680 KB Output is correct
99 Correct 4 ms 2680 KB Output is correct
100 Correct 4 ms 2680 KB Output is correct
101 Correct 4 ms 2680 KB Output is correct
102 Correct 4 ms 2680 KB Output is correct
103 Correct 4 ms 2680 KB Output is correct
104 Correct 12 ms 3576 KB Output is correct
105 Correct 21 ms 5112 KB Output is correct
106 Correct 4 ms 2680 KB Output is correct
107 Correct 38 ms 6520 KB Output is correct
108 Correct 47 ms 8056 KB Output is correct
109 Correct 5 ms 2680 KB Output is correct
110 Correct 75 ms 9720 KB Output is correct
111 Correct 92 ms 11504 KB Output is correct
112 Correct 5 ms 2808 KB Output is correct
113 Correct 132 ms 14580 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 6264 KB Output is correct
2 Incorrect 35 ms 6184 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 14964 KB Output is correct
2 Correct 80 ms 14836 KB Output is correct
3 Correct 49 ms 10868 KB Output is correct
4 Correct 15 ms 4600 KB Output is correct
5 Correct 14 ms 3704 KB Output is correct
6 Correct 26 ms 5496 KB Output is correct
7 Correct 5 ms 2680 KB Output is correct
8 Correct 44 ms 7032 KB Output is correct
9 Correct 62 ms 8824 KB Output is correct
10 Correct 5 ms 2804 KB Output is correct
11 Correct 110 ms 10872 KB Output is correct
12 Correct 98 ms 12652 KB Output is correct
13 Correct 6 ms 2808 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 5 ms 2808 KB Output is correct
16 Correct 5 ms 2808 KB Output is correct
17 Correct 5 ms 2808 KB Output is correct
18 Correct 5 ms 2808 KB Output is correct
19 Correct 6 ms 2808 KB Output is correct
20 Incorrect 5 ms 2680 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 77 ms 14964 KB Output is correct
2 Correct 80 ms 14836 KB Output is correct
3 Correct 49 ms 10868 KB Output is correct
4 Correct 15 ms 4600 KB Output is correct
5 Correct 14 ms 3704 KB Output is correct
6 Correct 26 ms 5496 KB Output is correct
7 Correct 5 ms 2680 KB Output is correct
8 Correct 44 ms 7032 KB Output is correct
9 Correct 62 ms 8824 KB Output is correct
10 Correct 5 ms 2804 KB Output is correct
11 Correct 110 ms 10872 KB Output is correct
12 Correct 98 ms 12652 KB Output is correct
13 Correct 6 ms 2808 KB Output is correct
14 Correct 5 ms 2680 KB Output is correct
15 Correct 5 ms 2680 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 5 ms 2680 KB Output is correct
18 Correct 5 ms 2680 KB Output is correct
19 Correct 4 ms 2680 KB Output is correct
20 Correct 5 ms 2680 KB Output is correct
21 Correct 5 ms 2680 KB Output is correct
22 Correct 7 ms 2680 KB Output is correct
23 Correct 5 ms 2680 KB Output is correct
24 Correct 5 ms 2680 KB Output is correct
25 Correct 5 ms 2680 KB Output is correct
26 Correct 4 ms 2680 KB Output is correct
27 Correct 4 ms 2680 KB Output is correct
28 Correct 4 ms 2680 KB Output is correct
29 Correct 4 ms 2680 KB Output is correct
30 Correct 4 ms 2680 KB Output is correct
31 Correct 5 ms 2680 KB Output is correct
32 Correct 4 ms 2680 KB Output is correct
33 Correct 5 ms 2680 KB Output is correct
34 Correct 5 ms 2680 KB Output is correct
35 Correct 4 ms 2680 KB Output is correct
36 Correct 5 ms 2680 KB Output is correct
37 Correct 5 ms 2684 KB Output is correct
38 Correct 4 ms 2680 KB Output is correct
39 Correct 78 ms 14840 KB Output is correct
40 Correct 74 ms 14836 KB Output is correct
41 Correct 49 ms 11000 KB Output is correct
42 Correct 14 ms 4600 KB Output is correct
43 Correct 4 ms 2680 KB Output is correct
44 Correct 4 ms 2680 KB Output is correct
45 Correct 4 ms 2680 KB Output is correct
46 Correct 4 ms 2680 KB Output is correct
47 Correct 4 ms 2680 KB Output is correct
48 Correct 5 ms 2680 KB Output is correct
49 Correct 4 ms 2680 KB Output is correct
50 Correct 4 ms 2680 KB Output is correct
51 Correct 4 ms 2680 KB Output is correct
52 Correct 4 ms 2680 KB Output is correct
53 Correct 5 ms 2680 KB Output is correct
54 Correct 4 ms 2680 KB Output is correct
55 Correct 5 ms 2680 KB Output is correct
56 Correct 4 ms 2680 KB Output is correct
57 Correct 105 ms 9196 KB Output is correct
58 Correct 115 ms 9076 KB Output is correct
59 Correct 169 ms 9072 KB Output is correct
60 Correct 157 ms 8920 KB Output is correct
61 Correct 107 ms 9048 KB Output is correct
62 Correct 101 ms 8952 KB Output is correct
63 Correct 100 ms 8880 KB Output is correct
64 Correct 133 ms 8944 KB Output is correct
65 Correct 110 ms 9000 KB Output is correct
66 Correct 134 ms 8920 KB Output is correct
67 Correct 161 ms 9156 KB Output is correct
68 Correct 140 ms 9168 KB Output is correct
69 Correct 106 ms 9076 KB Output is correct
70 Correct 115 ms 9076 KB Output is correct
71 Correct 4 ms 2680 KB Output is correct
72 Correct 7 ms 2924 KB Output is correct
73 Correct 6 ms 2936 KB Output is correct
74 Correct 6 ms 2936 KB Output is correct
75 Correct 6 ms 2936 KB Output is correct
76 Correct 6 ms 2936 KB Output is correct
77 Correct 6 ms 2936 KB Output is correct
78 Correct 6 ms 2940 KB Output is correct
79 Correct 6 ms 3064 KB Output is correct
80 Correct 101 ms 9332 KB Output is correct
81 Correct 97 ms 9068 KB Output is correct
82 Correct 104 ms 8948 KB Output is correct
83 Correct 108 ms 9104 KB Output is correct
84 Correct 5 ms 2808 KB Output is correct
85 Correct 5 ms 2808 KB Output is correct
86 Correct 6 ms 2808 KB Output is correct
87 Correct 6 ms 2864 KB Output is correct
88 Correct 5 ms 2936 KB Output is correct
89 Correct 6 ms 2808 KB Output is correct
90 Correct 6 ms 2808 KB Output is correct
91 Correct 6 ms 2808 KB Output is correct
92 Correct 6 ms 2808 KB Output is correct
93 Correct 6 ms 2808 KB Output is correct
94 Correct 5 ms 2680 KB Output is correct
95 Correct 5 ms 2680 KB Output is correct
96 Correct 5 ms 2680 KB Output is correct
97 Correct 4 ms 2680 KB Output is correct
98 Correct 4 ms 2680 KB Output is correct
99 Correct 4 ms 2680 KB Output is correct
100 Correct 4 ms 2680 KB Output is correct
101 Correct 4 ms 2680 KB Output is correct
102 Correct 4 ms 2680 KB Output is correct
103 Correct 4 ms 2680 KB Output is correct
104 Correct 12 ms 3576 KB Output is correct
105 Correct 21 ms 5112 KB Output is correct
106 Correct 4 ms 2680 KB Output is correct
107 Correct 38 ms 6520 KB Output is correct
108 Correct 47 ms 8056 KB Output is correct
109 Correct 5 ms 2680 KB Output is correct
110 Correct 75 ms 9720 KB Output is correct
111 Correct 92 ms 11504 KB Output is correct
112 Correct 5 ms 2808 KB Output is correct
113 Correct 132 ms 14580 KB Output is correct
114 Correct 35 ms 6264 KB Output is correct
115 Incorrect 35 ms 6184 KB Output isn't correct
116 Halted 0 ms 0 KB -