답안 #976242

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
976242 2024-05-06T10:46:44 Z Amaarsaa 꿈 (IOI13_dreaming) C++14
47 / 100
66 ms 16592 KB
#include<bits/stdc++.h>
#include "dreaming.h"
using namespace std;
vector < pair < int , int > > adj[100005];
int d[100004], used[100004];
int to[100005];
void dfs(int node, int parent, int dist) {
	d[node] = 0;
	to[node] = -1;
	used[node] = 1;
	for ( pair < int, int >& A : adj[node]) {
		int child = A.first;
		if ( child == parent) continue;
		dfs(child, node, dist + A.second);
		if ( d[node] < d[child] + A.second) {
			d[node] = d[child] + A.second;
			to[node] = child;
		}
	}
}
int ans = 0;
vector < int > Ans;
void Go(int x) {
	int y;
	dfs(x, x, 0);
	while(to[x] != -1) x = to[x];
	y = x;
	dfs(x, x, 0);
	int dist = d[x];
	vector < int > v;
	while (to[x] != -1) {
		v.push_back(x);
		x = to[x];
	}
	v.push_back(x);
	int s = 2e9;
	for ( int X : v) {
		s = min(s, max(d[X], dist -d[X])); 
	}
	ans = max(ans, dist);
	Ans.push_back(s);
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	for (int i = 0; i < M; i ++) {
		adj[A[i]].push_back({B[i], T[i]});
		adj[B[i]].push_back({A[i], T[i]});
	}
	for (int i = 0; i < N; i ++) {
		if (!used[i]) {
			Go(i);
		}
	}
	sort(Ans.rbegin(), Ans.rend());
//	if ( Ans.size() == 1) return ans;
	if ( Ans.size() == 2) return max(ans, Ans[0] + Ans[1] + L);
	return max(ans, max(Ans[0] + Ans[1] + L, Ans[1] + Ans[2] + 2 *L));
}

Compilation message

dreaming.cpp: In function 'void Go(int)':
dreaming.cpp:24:6: warning: variable 'y' set but not used [-Wunused-but-set-variable]
   24 |  int y;
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 16088 KB Output is correct
2 Correct 35 ms 15828 KB Output is correct
3 Correct 22 ms 12444 KB Output is correct
4 Correct 8 ms 6488 KB Output is correct
5 Correct 5 ms 5724 KB Output is correct
6 Correct 9 ms 7368 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 18 ms 8460 KB Output is correct
9 Correct 21 ms 10068 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 34 ms 11280 KB Output is correct
12 Correct 33 ms 13528 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 1 ms 4952 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4952 KB Output is correct
19 Correct 1 ms 4956 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 1 ms 4956 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 1 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 16088 KB Output is correct
2 Correct 35 ms 15828 KB Output is correct
3 Correct 22 ms 12444 KB Output is correct
4 Correct 8 ms 6488 KB Output is correct
5 Correct 5 ms 5724 KB Output is correct
6 Correct 9 ms 7368 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 18 ms 8460 KB Output is correct
9 Correct 21 ms 10068 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 34 ms 11280 KB Output is correct
12 Correct 33 ms 13528 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 1 ms 4952 KB Output is correct
19 Correct 1 ms 4956 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 2 ms 4952 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 1 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 1 ms 4956 KB Output is correct
26 Correct 1 ms 4956 KB Output is correct
27 Correct 1 ms 4956 KB Output is correct
28 Correct 1 ms 4952 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4952 KB Output is correct
31 Correct 1 ms 4952 KB Output is correct
32 Correct 1 ms 4956 KB Output is correct
33 Correct 1 ms 4956 KB Output is correct
34 Correct 1 ms 4956 KB Output is correct
35 Correct 1 ms 4956 KB Output is correct
36 Correct 1 ms 4956 KB Output is correct
37 Correct 1 ms 4956 KB Output is correct
38 Correct 2 ms 4956 KB Output is correct
39 Correct 33 ms 15784 KB Output is correct
40 Correct 36 ms 16084 KB Output is correct
41 Correct 22 ms 12240 KB Output is correct
42 Correct 6 ms 6492 KB Output is correct
43 Correct 1 ms 4956 KB Output is correct
44 Correct 1 ms 4956 KB Output is correct
45 Correct 2 ms 4956 KB Output is correct
46 Correct 1 ms 4956 KB Output is correct
47 Correct 1 ms 4956 KB Output is correct
48 Correct 1 ms 4956 KB Output is correct
49 Correct 1 ms 4956 KB Output is correct
50 Correct 1 ms 4956 KB Output is correct
51 Correct 1 ms 4956 KB Output is correct
52 Correct 1 ms 4956 KB Output is correct
53 Correct 1 ms 4956 KB Output is correct
54 Correct 1 ms 4956 KB Output is correct
55 Correct 1 ms 4956 KB Output is correct
56 Correct 1 ms 4956 KB Output is correct
57 Correct 40 ms 9472 KB Output is correct
58 Correct 37 ms 9196 KB Output is correct
59 Correct 37 ms 9300 KB Output is correct
60 Correct 36 ms 9296 KB Output is correct
61 Correct 38 ms 9300 KB Output is correct
62 Correct 36 ms 9120 KB Output is correct
63 Correct 40 ms 9052 KB Output is correct
64 Correct 33 ms 9044 KB Output is correct
65 Correct 35 ms 9300 KB Output is correct
66 Correct 35 ms 9424 KB Output is correct
67 Correct 38 ms 9300 KB Output is correct
68 Correct 37 ms 9044 KB Output is correct
69 Correct 40 ms 9556 KB Output is correct
70 Correct 37 ms 9124 KB Output is correct
71 Correct 1 ms 4952 KB Output is correct
72 Correct 2 ms 4956 KB Output is correct
73 Correct 2 ms 4956 KB Output is correct
74 Correct 2 ms 4956 KB Output is correct
75 Correct 3 ms 4956 KB Output is correct
76 Correct 2 ms 5212 KB Output is correct
77 Correct 2 ms 4956 KB Output is correct
78 Correct 2 ms 4956 KB Output is correct
79 Correct 2 ms 4956 KB Output is correct
80 Correct 37 ms 9564 KB Output is correct
81 Correct 45 ms 9300 KB Output is correct
82 Correct 36 ms 9272 KB Output is correct
83 Correct 41 ms 8992 KB Output is correct
84 Correct 2 ms 4956 KB Output is correct
85 Correct 2 ms 4956 KB Output is correct
86 Correct 2 ms 4972 KB Output is correct
87 Correct 2 ms 4956 KB Output is correct
88 Correct 2 ms 4956 KB Output is correct
89 Correct 2 ms 4956 KB Output is correct
90 Correct 2 ms 4956 KB Output is correct
91 Correct 2 ms 4956 KB Output is correct
92 Correct 2 ms 4956 KB Output is correct
93 Correct 2 ms 4956 KB Output is correct
94 Correct 1 ms 4952 KB Output is correct
95 Correct 1 ms 4956 KB Output is correct
96 Correct 2 ms 4952 KB Output is correct
97 Correct 1 ms 4956 KB Output is correct
98 Correct 1 ms 4956 KB Output is correct
99 Correct 1 ms 4956 KB Output is correct
100 Correct 1 ms 4956 KB Output is correct
101 Correct 1 ms 4952 KB Output is correct
102 Correct 2 ms 4956 KB Output is correct
103 Correct 2 ms 4956 KB Output is correct
104 Correct 6 ms 5724 KB Output is correct
105 Correct 9 ms 7260 KB Output is correct
106 Correct 1 ms 4956 KB Output is correct
107 Correct 17 ms 8416 KB Output is correct
108 Correct 22 ms 10080 KB Output is correct
109 Correct 1 ms 4956 KB Output is correct
110 Correct 33 ms 11484 KB Output is correct
111 Correct 35 ms 13640 KB Output is correct
112 Correct 2 ms 4952 KB Output is correct
113 Correct 66 ms 16592 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 7392 KB Output is correct
2 Correct 15 ms 7516 KB Output is correct
3 Correct 15 ms 7392 KB Output is correct
4 Correct 15 ms 7384 KB Output is correct
5 Correct 14 ms 7388 KB Output is correct
6 Correct 16 ms 7804 KB Output is correct
7 Correct 16 ms 7512 KB Output is correct
8 Correct 17 ms 7260 KB Output is correct
9 Correct 15 ms 7384 KB Output is correct
10 Correct 15 ms 7640 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 5 ms 5592 KB Output is correct
13 Correct 5 ms 5592 KB Output is correct
14 Correct 5 ms 5592 KB Output is correct
15 Correct 5 ms 5588 KB Output is correct
16 Correct 5 ms 5592 KB Output is correct
17 Correct 5 ms 5592 KB Output is correct
18 Correct 5 ms 5588 KB Output is correct
19 Correct 5 ms 5588 KB Output is correct
20 Incorrect 1 ms 4956 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4952 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4952 KB Output is correct
9 Correct 1 ms 4956 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 1 ms 4956 KB Output is correct
12 Correct 1 ms 4956 KB Output is correct
13 Correct 1 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 1 ms 4952 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 1 ms 4952 KB Output is correct
18 Correct 1 ms 4952 KB Output is correct
19 Correct 1 ms 4956 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 1 ms 4956 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 1 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 1 ms 4956 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 2 ms 4952 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 2 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 2 ms 4956 KB Output is correct
34 Correct 2 ms 4956 KB Output is correct
35 Correct 1 ms 4956 KB Output is correct
36 Correct 1 ms 4956 KB Output is correct
37 Correct 2 ms 4956 KB Output is correct
38 Correct 1 ms 4956 KB Output is correct
39 Correct 1 ms 4956 KB Output is correct
40 Correct 1 ms 4956 KB Output is correct
41 Correct 2 ms 4956 KB Output is correct
42 Correct 1 ms 4956 KB Output is correct
43 Correct 1 ms 4956 KB Output is correct
44 Correct 1 ms 4952 KB Output is correct
45 Correct 2 ms 4952 KB Output is correct
46 Correct 1 ms 4956 KB Output is correct
47 Correct 1 ms 4956 KB Output is correct
48 Correct 1 ms 4956 KB Output is correct
49 Correct 1 ms 4956 KB Output is correct
50 Correct 1 ms 4956 KB Output is correct
51 Correct 1 ms 4956 KB Output is correct
52 Incorrect 1 ms 4956 KB Output isn't correct
53 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 44 ms 16088 KB Output is correct
2 Correct 35 ms 15828 KB Output is correct
3 Correct 22 ms 12444 KB Output is correct
4 Correct 8 ms 6488 KB Output is correct
5 Correct 5 ms 5724 KB Output is correct
6 Correct 9 ms 7368 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 18 ms 8460 KB Output is correct
9 Correct 21 ms 10068 KB Output is correct
10 Correct 1 ms 4956 KB Output is correct
11 Correct 34 ms 11280 KB Output is correct
12 Correct 33 ms 13528 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 1 ms 4956 KB Output is correct
15 Correct 1 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 1 ms 4956 KB Output is correct
18 Correct 1 ms 4952 KB Output is correct
19 Correct 1 ms 4956 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 2 ms 4952 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 1 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 1 ms 4956 KB Output is correct
26 Correct 1 ms 4956 KB Output is correct
27 Correct 1 ms 4956 KB Output is correct
28 Correct 1 ms 4952 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4952 KB Output is correct
31 Correct 1 ms 4952 KB Output is correct
32 Correct 1 ms 4956 KB Output is correct
33 Correct 1 ms 4956 KB Output is correct
34 Correct 1 ms 4956 KB Output is correct
35 Correct 1 ms 4956 KB Output is correct
36 Correct 1 ms 4956 KB Output is correct
37 Correct 1 ms 4956 KB Output is correct
38 Correct 2 ms 4956 KB Output is correct
39 Correct 33 ms 15784 KB Output is correct
40 Correct 36 ms 16084 KB Output is correct
41 Correct 22 ms 12240 KB Output is correct
42 Correct 6 ms 6492 KB Output is correct
43 Correct 1 ms 4956 KB Output is correct
44 Correct 1 ms 4956 KB Output is correct
45 Correct 2 ms 4956 KB Output is correct
46 Correct 1 ms 4956 KB Output is correct
47 Correct 1 ms 4956 KB Output is correct
48 Correct 1 ms 4956 KB Output is correct
49 Correct 1 ms 4956 KB Output is correct
50 Correct 1 ms 4956 KB Output is correct
51 Correct 1 ms 4956 KB Output is correct
52 Correct 1 ms 4956 KB Output is correct
53 Correct 1 ms 4956 KB Output is correct
54 Correct 1 ms 4956 KB Output is correct
55 Correct 1 ms 4956 KB Output is correct
56 Correct 1 ms 4956 KB Output is correct
57 Correct 40 ms 9472 KB Output is correct
58 Correct 37 ms 9196 KB Output is correct
59 Correct 37 ms 9300 KB Output is correct
60 Correct 36 ms 9296 KB Output is correct
61 Correct 38 ms 9300 KB Output is correct
62 Correct 36 ms 9120 KB Output is correct
63 Correct 40 ms 9052 KB Output is correct
64 Correct 33 ms 9044 KB Output is correct
65 Correct 35 ms 9300 KB Output is correct
66 Correct 35 ms 9424 KB Output is correct
67 Correct 38 ms 9300 KB Output is correct
68 Correct 37 ms 9044 KB Output is correct
69 Correct 40 ms 9556 KB Output is correct
70 Correct 37 ms 9124 KB Output is correct
71 Correct 1 ms 4952 KB Output is correct
72 Correct 2 ms 4956 KB Output is correct
73 Correct 2 ms 4956 KB Output is correct
74 Correct 2 ms 4956 KB Output is correct
75 Correct 3 ms 4956 KB Output is correct
76 Correct 2 ms 5212 KB Output is correct
77 Correct 2 ms 4956 KB Output is correct
78 Correct 2 ms 4956 KB Output is correct
79 Correct 2 ms 4956 KB Output is correct
80 Correct 37 ms 9564 KB Output is correct
81 Correct 45 ms 9300 KB Output is correct
82 Correct 36 ms 9272 KB Output is correct
83 Correct 41 ms 8992 KB Output is correct
84 Correct 2 ms 4956 KB Output is correct
85 Correct 2 ms 4956 KB Output is correct
86 Correct 2 ms 4972 KB Output is correct
87 Correct 2 ms 4956 KB Output is correct
88 Correct 2 ms 4956 KB Output is correct
89 Correct 2 ms 4956 KB Output is correct
90 Correct 2 ms 4956 KB Output is correct
91 Correct 2 ms 4956 KB Output is correct
92 Correct 2 ms 4956 KB Output is correct
93 Correct 2 ms 4956 KB Output is correct
94 Correct 1 ms 4952 KB Output is correct
95 Correct 1 ms 4956 KB Output is correct
96 Correct 2 ms 4952 KB Output is correct
97 Correct 1 ms 4956 KB Output is correct
98 Correct 1 ms 4956 KB Output is correct
99 Correct 1 ms 4956 KB Output is correct
100 Correct 1 ms 4956 KB Output is correct
101 Correct 1 ms 4952 KB Output is correct
102 Correct 2 ms 4956 KB Output is correct
103 Correct 2 ms 4956 KB Output is correct
104 Correct 6 ms 5724 KB Output is correct
105 Correct 9 ms 7260 KB Output is correct
106 Correct 1 ms 4956 KB Output is correct
107 Correct 17 ms 8416 KB Output is correct
108 Correct 22 ms 10080 KB Output is correct
109 Correct 1 ms 4956 KB Output is correct
110 Correct 33 ms 11484 KB Output is correct
111 Correct 35 ms 13640 KB Output is correct
112 Correct 2 ms 4952 KB Output is correct
113 Correct 66 ms 16592 KB Output is correct
114 Correct 18 ms 7392 KB Output is correct
115 Correct 15 ms 7516 KB Output is correct
116 Correct 15 ms 7392 KB Output is correct
117 Correct 15 ms 7384 KB Output is correct
118 Correct 14 ms 7388 KB Output is correct
119 Correct 16 ms 7804 KB Output is correct
120 Correct 16 ms 7512 KB Output is correct
121 Correct 17 ms 7260 KB Output is correct
122 Correct 15 ms 7384 KB Output is correct
123 Correct 15 ms 7640 KB Output is correct
124 Correct 1 ms 4956 KB Output is correct
125 Correct 5 ms 5592 KB Output is correct
126 Correct 5 ms 5592 KB Output is correct
127 Correct 5 ms 5592 KB Output is correct
128 Correct 5 ms 5588 KB Output is correct
129 Correct 5 ms 5592 KB Output is correct
130 Correct 5 ms 5592 KB Output is correct
131 Correct 5 ms 5588 KB Output is correct
132 Correct 5 ms 5588 KB Output is correct
133 Incorrect 1 ms 4956 KB Output isn't correct
134 Halted 0 ms 0 KB -