답안 #28990

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
28990 2017-07-18T03:49:55 Z nibnalin 꿈 (IOI13_dreaming) C++14
59 / 100
1000 ms 16628 KB
#include <iostream>
#include <cstdio>
#include <vector>
#include <set>
#include <algorithm>
#include "dreaming.h"
using namespace std;

const int maxn = int(1e5)+5, inf = int(2e9)+5;

int n, m, l, D[2][maxn], vis[maxn];
vector<int> cur_comp;
vector<pair<int, int>> guys, graph[maxn];

int dfs(int node, int par, int d, int type)
{
	D[type][node] = d;
	if(type) cur_comp.push_back(node);
	int cur = node;
	for(auto it: graph[node])
	{
		if(it.first != par)
		{
			int tmp = dfs(it.first, node, d+it.second, type);
			if(D[type][cur] < D[type][tmp]) cur = tmp;
		}
	}
	return cur;
}


int travelTime(int _N, int _M, int _L, int _A[], int _B[], int _T[]) {
	n = _N, m = _M, l = _L;
	for(int i = 0;i < m;i++)
	{
		graph[_A[i]].push_back({_B[i], _T[i]});
		graph[_B[i]].push_back({_A[i], _T[i]});
	}

	int prev = -1;
	for(int i = 0;i < n;i++)
	{
		if(!vis[i])
		{
			cur_comp.clear();
			int f1 = dfs(i, -1, 0, 0);
			int f2 = dfs(f1, -1, 0, 0);
			dfs(f2, -1, 0, 1);
			pair<int, int> mini = {inf, inf};
			for(auto it: cur_comp)
			{
				mini = min(mini, {max(D[0][it], D[1][it]), it});
				vis[it] = 1;
			}
			guys.push_back(mini);
		}
	}
	sort(guys.rbegin(), guys.rend());
	for(auto it: guys)
	{
		if(prev == -1)
		{
			prev = it.second;
			continue;
		}

		graph[prev].push_back({it.second, l});
		graph[it.second].push_back({prev, l});

		cur_comp.clear();
		int f1 = dfs(prev, -1, 0, 0);
		int f2 = dfs(f1, -1, 0, 0);
		dfs(f2, -1, 0, 1);
		pair<int, int> mini = {inf, inf};
		for(auto it: cur_comp)
		{
			mini = min(mini, {max(D[0][it], D[1][it]), it});
			vis[it] = 1;
		}
		prev = mini.second;
	}

	int f1 = dfs(prev, -1, 0, 0);
	int f2 = dfs(f1, -1, 0, 0);
	return D[0][f2];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 15348 KB Output is correct
2 Correct 159 ms 15348 KB Output is correct
3 Correct 58 ms 10996 KB Output is correct
4 Correct 14 ms 4608 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 25 ms 5624 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 43 ms 7172 KB Output is correct
9 Correct 55 ms 8828 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 84 ms 10908 KB Output is correct
12 Correct 127 ms 12976 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 15348 KB Output is correct
2 Correct 159 ms 15348 KB Output is correct
3 Correct 58 ms 10996 KB Output is correct
4 Correct 14 ms 4608 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 25 ms 5624 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 43 ms 7172 KB Output is correct
9 Correct 55 ms 8828 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 84 ms 10908 KB Output is correct
12 Correct 127 ms 12976 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
14 Correct 3 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 5 ms 2688 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 4 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2660 KB Output is correct
27 Correct 4 ms 2688 KB Output is correct
28 Correct 5 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 5 ms 2652 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2688 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 3 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 4 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 15348 KB Output is correct
2 Correct 159 ms 15348 KB Output is correct
3 Correct 58 ms 10996 KB Output is correct
4 Correct 14 ms 4608 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 25 ms 5624 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 43 ms 7172 KB Output is correct
9 Correct 55 ms 8828 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 84 ms 10908 KB Output is correct
12 Correct 127 ms 12976 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
14 Correct 3 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 5 ms 2688 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 4 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2660 KB Output is correct
27 Correct 4 ms 2688 KB Output is correct
28 Correct 5 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 5 ms 2652 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2688 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 3 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 4 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
39 Correct 123 ms 15336 KB Output is correct
40 Correct 113 ms 15220 KB Output is correct
41 Correct 55 ms 11124 KB Output is correct
42 Correct 18 ms 4608 KB Output is correct
43 Correct 4 ms 2688 KB Output is correct
44 Correct 4 ms 2688 KB Output is correct
45 Correct 4 ms 2688 KB Output is correct
46 Correct 4 ms 2688 KB Output is correct
47 Correct 4 ms 2688 KB Output is correct
48 Correct 4 ms 2688 KB Output is correct
49 Correct 4 ms 2688 KB Output is correct
50 Correct 4 ms 2688 KB Output is correct
51 Correct 4 ms 2688 KB Output is correct
52 Correct 4 ms 2688 KB Output is correct
53 Correct 4 ms 2688 KB Output is correct
54 Correct 4 ms 2688 KB Output is correct
55 Correct 4 ms 2688 KB Output is correct
56 Correct 4 ms 2688 KB Output is correct
57 Correct 187 ms 9680 KB Output is correct
58 Correct 198 ms 9728 KB Output is correct
59 Correct 195 ms 9628 KB Output is correct
60 Correct 171 ms 9716 KB Output is correct
61 Correct 131 ms 9436 KB Output is correct
62 Correct 186 ms 9560 KB Output is correct
63 Correct 115 ms 9336 KB Output is correct
64 Correct 134 ms 9304 KB Output is correct
65 Correct 140 ms 9268 KB Output is correct
66 Correct 133 ms 9204 KB Output is correct
67 Correct 150 ms 9456 KB Output is correct
68 Correct 145 ms 9492 KB Output is correct
69 Correct 125 ms 9716 KB Output is correct
70 Correct 122 ms 9588 KB Output is correct
71 Correct 3 ms 2688 KB Output is correct
72 Correct 6 ms 2944 KB Output is correct
73 Correct 6 ms 2944 KB Output is correct
74 Correct 6 ms 2944 KB Output is correct
75 Correct 6 ms 2944 KB Output is correct
76 Correct 6 ms 2944 KB Output is correct
77 Correct 6 ms 2944 KB Output is correct
78 Correct 6 ms 2944 KB Output is correct
79 Correct 6 ms 2944 KB Output is correct
80 Correct 210 ms 9588 KB Output is correct
81 Correct 134 ms 9456 KB Output is correct
82 Correct 120 ms 9392 KB Output is correct
83 Correct 158 ms 9596 KB Output is correct
84 Correct 5 ms 2944 KB Output is correct
85 Correct 5 ms 2944 KB Output is correct
86 Correct 6 ms 2944 KB Output is correct
87 Correct 5 ms 2816 KB Output is correct
88 Correct 6 ms 2944 KB Output is correct
89 Correct 5 ms 2816 KB Output is correct
90 Correct 5 ms 2944 KB Output is correct
91 Correct 5 ms 2944 KB Output is correct
92 Correct 6 ms 2944 KB Output is correct
93 Correct 5 ms 2816 KB Output is correct
94 Correct 3 ms 2688 KB Output is correct
95 Correct 4 ms 2688 KB Output is correct
96 Correct 4 ms 2688 KB Output is correct
97 Correct 3 ms 2688 KB Output is correct
98 Correct 4 ms 2688 KB Output is correct
99 Correct 4 ms 2688 KB Output is correct
100 Correct 4 ms 2688 KB Output is correct
101 Correct 3 ms 2688 KB Output is correct
102 Correct 5 ms 2688 KB Output is correct
103 Correct 4 ms 2688 KB Output is correct
104 Correct 14 ms 3716 KB Output is correct
105 Correct 26 ms 5504 KB Output is correct
106 Correct 5 ms 2816 KB Output is correct
107 Correct 45 ms 7156 KB Output is correct
108 Correct 59 ms 8952 KB Output is correct
109 Correct 4 ms 2716 KB Output is correct
110 Correct 119 ms 10912 KB Output is correct
111 Correct 172 ms 13040 KB Output is correct
112 Correct 4 ms 2816 KB Output is correct
113 Correct 229 ms 16628 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Execution timed out 1064 ms 6772 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 15348 KB Output is correct
2 Correct 159 ms 15348 KB Output is correct
3 Correct 58 ms 10996 KB Output is correct
4 Correct 14 ms 4608 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 25 ms 5624 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 43 ms 7172 KB Output is correct
9 Correct 55 ms 8828 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 84 ms 10908 KB Output is correct
12 Correct 127 ms 12976 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
14 Correct 8 ms 2816 KB Output is correct
15 Correct 20 ms 2816 KB Output is correct
16 Correct 49 ms 2944 KB Output is correct
17 Correct 7 ms 2816 KB Output is correct
18 Correct 18 ms 2788 KB Output is correct
19 Correct 40 ms 2944 KB Output is correct
20 Correct 8 ms 2816 KB Output is correct
21 Correct 17 ms 2816 KB Output is correct
22 Correct 36 ms 2944 KB Output is correct
23 Correct 4 ms 2660 KB Output is correct
24 Correct 3 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2688 KB Output is correct
27 Correct 4 ms 2688 KB Output is correct
28 Correct 4 ms 2764 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 4 ms 2688 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2688 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 4 ms 2688 KB Output is correct
35 Correct 4 ms 2688 KB Output is correct
36 Correct 4 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
39 Correct 4 ms 2688 KB Output is correct
40 Correct 4 ms 2688 KB Output is correct
41 Correct 4 ms 2688 KB Output is correct
42 Correct 6 ms 3072 KB Output is correct
43 Correct 6 ms 3072 KB Output is correct
44 Correct 101 ms 3064 KB Output is correct
45 Correct 133 ms 2936 KB Output is correct
46 Correct 6 ms 2944 KB Output is correct
47 Correct 6 ms 2944 KB Output is correct
48 Correct 113 ms 3056 KB Output is correct
49 Correct 118 ms 2936 KB Output is correct
50 Correct 7 ms 2944 KB Output is correct
51 Correct 6 ms 2944 KB Output is correct
52 Correct 113 ms 2940 KB Output is correct
53 Correct 100 ms 2944 KB Output is correct
54 Correct 6 ms 2944 KB Output is correct
55 Correct 6 ms 2944 KB Output is correct
56 Correct 87 ms 2944 KB Output is correct
57 Correct 89 ms 2944 KB Output is correct
58 Correct 123 ms 2964 KB Output is correct
59 Correct 124 ms 2944 KB Output is correct
60 Correct 5 ms 2944 KB Output is correct
61 Correct 5 ms 2944 KB Output is correct
62 Correct 31 ms 2944 KB Output is correct
63 Correct 27 ms 2944 KB Output is correct
64 Correct 6 ms 2944 KB Output is correct
65 Correct 6 ms 2944 KB Output is correct
66 Correct 116 ms 2816 KB Output is correct
67 Correct 116 ms 2936 KB Output is correct
68 Correct 120 ms 2936 KB Output is correct
69 Correct 101 ms 2920 KB Output is correct
70 Correct 58 ms 2928 KB Output is correct
71 Correct 47 ms 2944 KB Output is correct
72 Correct 129 ms 2816 KB Output is correct
73 Correct 121 ms 2952 KB Output is correct
74 Correct 134 ms 2960 KB Output is correct
75 Correct 43 ms 2944 KB Output is correct
76 Correct 86 ms 2932 KB Output is correct
77 Correct 95 ms 2944 KB Output is correct
78 Correct 109 ms 3064 KB Output is correct
79 Correct 114 ms 2936 KB Output is correct
80 Correct 4 ms 2816 KB Output is correct
81 Correct 4 ms 2816 KB Output is correct
82 Correct 5 ms 2944 KB Output is correct
83 Correct 5 ms 2944 KB Output is correct
84 Correct 5 ms 2944 KB Output is correct
85 Correct 5 ms 2944 KB Output is correct
86 Correct 5 ms 2816 KB Output is correct
87 Correct 6 ms 2944 KB Output is correct
88 Correct 6 ms 2944 KB Output is correct
89 Correct 6 ms 2944 KB Output is correct
90 Correct 4 ms 2688 KB Output is correct
91 Correct 4 ms 2688 KB Output is correct
92 Correct 4 ms 2688 KB Output is correct
93 Correct 4 ms 2688 KB Output is correct
94 Correct 3 ms 2688 KB Output is correct
95 Correct 4 ms 2688 KB Output is correct
96 Correct 4 ms 2688 KB Output is correct
97 Correct 4 ms 2688 KB Output is correct
98 Correct 4 ms 2688 KB Output is correct
99 Correct 4 ms 2688 KB Output is correct
100 Correct 4 ms 2688 KB Output is correct
101 Correct 4 ms 2816 KB Output is correct
102 Correct 4 ms 2816 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 91 ms 15348 KB Output is correct
2 Correct 159 ms 15348 KB Output is correct
3 Correct 58 ms 10996 KB Output is correct
4 Correct 14 ms 4608 KB Output is correct
5 Correct 13 ms 3712 KB Output is correct
6 Correct 25 ms 5624 KB Output is correct
7 Correct 4 ms 2688 KB Output is correct
8 Correct 43 ms 7172 KB Output is correct
9 Correct 55 ms 8828 KB Output is correct
10 Correct 4 ms 2816 KB Output is correct
11 Correct 84 ms 10908 KB Output is correct
12 Correct 127 ms 12976 KB Output is correct
13 Correct 4 ms 2816 KB Output is correct
14 Correct 3 ms 2688 KB Output is correct
15 Correct 4 ms 2688 KB Output is correct
16 Correct 4 ms 2688 KB Output is correct
17 Correct 4 ms 2688 KB Output is correct
18 Correct 4 ms 2688 KB Output is correct
19 Correct 4 ms 2688 KB Output is correct
20 Correct 4 ms 2688 KB Output is correct
21 Correct 4 ms 2688 KB Output is correct
22 Correct 5 ms 2688 KB Output is correct
23 Correct 4 ms 2688 KB Output is correct
24 Correct 4 ms 2688 KB Output is correct
25 Correct 4 ms 2688 KB Output is correct
26 Correct 4 ms 2660 KB Output is correct
27 Correct 4 ms 2688 KB Output is correct
28 Correct 5 ms 2688 KB Output is correct
29 Correct 4 ms 2688 KB Output is correct
30 Correct 5 ms 2652 KB Output is correct
31 Correct 4 ms 2688 KB Output is correct
32 Correct 4 ms 2688 KB Output is correct
33 Correct 4 ms 2688 KB Output is correct
34 Correct 3 ms 2688 KB Output is correct
35 Correct 3 ms 2688 KB Output is correct
36 Correct 4 ms 2688 KB Output is correct
37 Correct 4 ms 2688 KB Output is correct
38 Correct 4 ms 2688 KB Output is correct
39 Correct 123 ms 15336 KB Output is correct
40 Correct 113 ms 15220 KB Output is correct
41 Correct 55 ms 11124 KB Output is correct
42 Correct 18 ms 4608 KB Output is correct
43 Correct 4 ms 2688 KB Output is correct
44 Correct 4 ms 2688 KB Output is correct
45 Correct 4 ms 2688 KB Output is correct
46 Correct 4 ms 2688 KB Output is correct
47 Correct 4 ms 2688 KB Output is correct
48 Correct 4 ms 2688 KB Output is correct
49 Correct 4 ms 2688 KB Output is correct
50 Correct 4 ms 2688 KB Output is correct
51 Correct 4 ms 2688 KB Output is correct
52 Correct 4 ms 2688 KB Output is correct
53 Correct 4 ms 2688 KB Output is correct
54 Correct 4 ms 2688 KB Output is correct
55 Correct 4 ms 2688 KB Output is correct
56 Correct 4 ms 2688 KB Output is correct
57 Correct 187 ms 9680 KB Output is correct
58 Correct 198 ms 9728 KB Output is correct
59 Correct 195 ms 9628 KB Output is correct
60 Correct 171 ms 9716 KB Output is correct
61 Correct 131 ms 9436 KB Output is correct
62 Correct 186 ms 9560 KB Output is correct
63 Correct 115 ms 9336 KB Output is correct
64 Correct 134 ms 9304 KB Output is correct
65 Correct 140 ms 9268 KB Output is correct
66 Correct 133 ms 9204 KB Output is correct
67 Correct 150 ms 9456 KB Output is correct
68 Correct 145 ms 9492 KB Output is correct
69 Correct 125 ms 9716 KB Output is correct
70 Correct 122 ms 9588 KB Output is correct
71 Correct 3 ms 2688 KB Output is correct
72 Correct 6 ms 2944 KB Output is correct
73 Correct 6 ms 2944 KB Output is correct
74 Correct 6 ms 2944 KB Output is correct
75 Correct 6 ms 2944 KB Output is correct
76 Correct 6 ms 2944 KB Output is correct
77 Correct 6 ms 2944 KB Output is correct
78 Correct 6 ms 2944 KB Output is correct
79 Correct 6 ms 2944 KB Output is correct
80 Correct 210 ms 9588 KB Output is correct
81 Correct 134 ms 9456 KB Output is correct
82 Correct 120 ms 9392 KB Output is correct
83 Correct 158 ms 9596 KB Output is correct
84 Correct 5 ms 2944 KB Output is correct
85 Correct 5 ms 2944 KB Output is correct
86 Correct 6 ms 2944 KB Output is correct
87 Correct 5 ms 2816 KB Output is correct
88 Correct 6 ms 2944 KB Output is correct
89 Correct 5 ms 2816 KB Output is correct
90 Correct 5 ms 2944 KB Output is correct
91 Correct 5 ms 2944 KB Output is correct
92 Correct 6 ms 2944 KB Output is correct
93 Correct 5 ms 2816 KB Output is correct
94 Correct 3 ms 2688 KB Output is correct
95 Correct 4 ms 2688 KB Output is correct
96 Correct 4 ms 2688 KB Output is correct
97 Correct 3 ms 2688 KB Output is correct
98 Correct 4 ms 2688 KB Output is correct
99 Correct 4 ms 2688 KB Output is correct
100 Correct 4 ms 2688 KB Output is correct
101 Correct 3 ms 2688 KB Output is correct
102 Correct 5 ms 2688 KB Output is correct
103 Correct 4 ms 2688 KB Output is correct
104 Correct 14 ms 3716 KB Output is correct
105 Correct 26 ms 5504 KB Output is correct
106 Correct 5 ms 2816 KB Output is correct
107 Correct 45 ms 7156 KB Output is correct
108 Correct 59 ms 8952 KB Output is correct
109 Correct 4 ms 2716 KB Output is correct
110 Correct 119 ms 10912 KB Output is correct
111 Correct 172 ms 13040 KB Output is correct
112 Correct 4 ms 2816 KB Output is correct
113 Correct 229 ms 16628 KB Output is correct
114 Execution timed out 1064 ms 6772 KB Time limit exceeded
115 Halted 0 ms 0 KB -