답안 #672601

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
672601 2022-12-16T21:18:48 Z Hacv16 꿈 (IOI13_dreaming) C++17
47 / 100
88 ms 59820 KB
#include<bits/stdc++.h>
#include"dreaming.h"
using namespace std;

const int MAX = 2e6 + 15;
const int INF = 0x3f3f3f3f;

#define fr first
#define sc second

int mxdiam, dist[MAX], pai[MAX], seen[MAX];
vector<pair<int, int>> adj[MAX];
int mx, id;

void dfs(int u, int p, int d, bool f){
	seen[u] = true;
	mxdiam = max(d, mxdiam);

	if(d > mx) mx = d, id = u;
	if(f) pai[u] = p, dist[u] = d; 

	for(auto e : adj[u]){
		int v = e.fr, w = e.sc;
		if(v == p) continue;

		dfs(v, u, d + w, f);
	}
}

int getRadius(int u){
	mx = -1, id = 0;

	dfs(u, -1, 0, 0);

	int ponta1 = id;
	mx = -1, id = 0;

	dfs(ponta1, -1, 0, 1);

	vector<int> path;
	int ponta2 = id;
	int cur = ponta2;

	while(cur != -1){
		path.push_back(cur);
		cur = pai[cur];
	}

	int mndiff = INF, idx = u;

	for(auto c : path){
		int cur = abs(dist[c] - (dist[ponta2] - dist[c]));
		if(cur < mndiff) mndiff = cur, idx = c;
	}

	return max(dist[idx], dist[ponta2] - dist[idx]);
}

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> rad;

	for(int i = 0; i < n; i++){
		if(seen[i]) continue;
		int r = getRadius(i);
		rad.push_back(r);
	}

	sort(rad.begin(), rad.end());

	int op1 = (rad.size() > 1 ? L + rad.back() + rad[rad.size() - 2] : INF);
	int op2 = (rad.size() > 2 ? 2 * L + rad[rad.size() - 2] + rad[rad.size() - 3] : INF);

	return max(mxdiam, min(op1, op2));
}
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 58596 KB Output is correct
2 Correct 61 ms 58676 KB Output is correct
3 Correct 47 ms 54716 KB Output is correct
4 Correct 28 ms 48944 KB Output is correct
5 Correct 25 ms 48200 KB Output is correct
6 Correct 32 ms 49956 KB Output is correct
7 Correct 22 ms 47292 KB Output is correct
8 Correct 43 ms 51352 KB Output is correct
9 Correct 53 ms 53124 KB Output is correct
10 Correct 21 ms 47316 KB Output is correct
11 Correct 56 ms 54604 KB Output is correct
12 Correct 67 ms 56780 KB Output is correct
13 Correct 22 ms 47384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 47384 KB Output is correct
2 Correct 22 ms 47316 KB Output is correct
3 Correct 22 ms 47188 KB Output is correct
4 Correct 21 ms 47200 KB Output is correct
5 Correct 22 ms 47280 KB Output is correct
6 Correct 22 ms 47280 KB Output is correct
7 Correct 22 ms 47188 KB Output is correct
8 Correct 21 ms 47276 KB Output is correct
9 Correct 22 ms 47236 KB Output is correct
10 Correct 21 ms 47252 KB Output is correct
11 Correct 26 ms 47204 KB Output is correct
12 Correct 23 ms 47316 KB Output is correct
13 Correct 25 ms 47292 KB Output is correct
14 Correct 22 ms 47196 KB Output is correct
15 Correct 21 ms 47264 KB Output is correct
16 Correct 23 ms 47280 KB Output is correct
17 Correct 22 ms 47288 KB Output is correct
18 Correct 22 ms 47280 KB Output is correct
19 Correct 22 ms 47188 KB Output is correct
20 Correct 21 ms 47316 KB Output is correct
21 Correct 22 ms 47244 KB Output is correct
22 Correct 23 ms 47280 KB Output is correct
23 Correct 24 ms 47188 KB Output is correct
24 Correct 22 ms 47316 KB Output is correct
25 Correct 24 ms 47288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 58596 KB Output is correct
2 Correct 61 ms 58676 KB Output is correct
3 Correct 47 ms 54716 KB Output is correct
4 Correct 28 ms 48944 KB Output is correct
5 Correct 25 ms 48200 KB Output is correct
6 Correct 32 ms 49956 KB Output is correct
7 Correct 22 ms 47292 KB Output is correct
8 Correct 43 ms 51352 KB Output is correct
9 Correct 53 ms 53124 KB Output is correct
10 Correct 21 ms 47316 KB Output is correct
11 Correct 56 ms 54604 KB Output is correct
12 Correct 67 ms 56780 KB Output is correct
13 Correct 22 ms 47384 KB Output is correct
14 Correct 24 ms 47384 KB Output is correct
15 Correct 22 ms 47316 KB Output is correct
16 Correct 22 ms 47188 KB Output is correct
17 Correct 21 ms 47200 KB Output is correct
18 Correct 22 ms 47280 KB Output is correct
19 Correct 22 ms 47280 KB Output is correct
20 Correct 22 ms 47188 KB Output is correct
21 Correct 21 ms 47276 KB Output is correct
22 Correct 22 ms 47236 KB Output is correct
23 Correct 21 ms 47252 KB Output is correct
24 Correct 26 ms 47204 KB Output is correct
25 Correct 23 ms 47316 KB Output is correct
26 Correct 25 ms 47292 KB Output is correct
27 Correct 22 ms 47196 KB Output is correct
28 Correct 21 ms 47264 KB Output is correct
29 Correct 23 ms 47280 KB Output is correct
30 Correct 22 ms 47288 KB Output is correct
31 Correct 22 ms 47280 KB Output is correct
32 Correct 22 ms 47188 KB Output is correct
33 Correct 21 ms 47316 KB Output is correct
34 Correct 22 ms 47244 KB Output is correct
35 Correct 23 ms 47280 KB Output is correct
36 Correct 24 ms 47188 KB Output is correct
37 Correct 22 ms 47316 KB Output is correct
38 Correct 24 ms 47288 KB Output is correct
39 Correct 68 ms 58772 KB Output is correct
40 Correct 77 ms 58788 KB Output is correct
41 Correct 48 ms 54776 KB Output is correct
42 Correct 28 ms 49088 KB Output is correct
43 Correct 22 ms 47288 KB Output is correct
44 Correct 22 ms 47236 KB Output is correct
45 Correct 22 ms 47276 KB Output is correct
46 Correct 23 ms 47188 KB Output is correct
47 Correct 22 ms 47316 KB Output is correct
48 Correct 21 ms 47252 KB Output is correct
49 Correct 23 ms 47316 KB Output is correct
50 Correct 23 ms 47232 KB Output is correct
51 Correct 24 ms 47256 KB Output is correct
52 Correct 23 ms 47316 KB Output is correct
53 Correct 23 ms 47280 KB Output is correct
54 Correct 22 ms 47316 KB Output is correct
55 Correct 22 ms 47224 KB Output is correct
56 Correct 21 ms 47288 KB Output is correct
57 Correct 71 ms 53796 KB Output is correct
58 Correct 75 ms 53752 KB Output is correct
59 Correct 72 ms 53668 KB Output is correct
60 Correct 69 ms 53668 KB Output is correct
61 Correct 70 ms 53636 KB Output is correct
62 Correct 78 ms 53648 KB Output is correct
63 Correct 74 ms 53452 KB Output is correct
64 Correct 71 ms 53436 KB Output is correct
65 Correct 65 ms 53440 KB Output is correct
66 Correct 69 ms 53448 KB Output is correct
67 Correct 70 ms 53672 KB Output is correct
68 Correct 68 ms 53664 KB Output is correct
69 Correct 73 ms 53656 KB Output is correct
70 Correct 71 ms 53676 KB Output is correct
71 Correct 23 ms 47304 KB Output is correct
72 Correct 23 ms 47504 KB Output is correct
73 Correct 22 ms 47468 KB Output is correct
74 Correct 23 ms 47436 KB Output is correct
75 Correct 23 ms 47420 KB Output is correct
76 Correct 27 ms 47460 KB Output is correct
77 Correct 23 ms 47444 KB Output is correct
78 Correct 23 ms 47444 KB Output is correct
79 Correct 23 ms 47460 KB Output is correct
80 Correct 74 ms 53680 KB Output is correct
81 Correct 71 ms 53700 KB Output is correct
82 Correct 76 ms 53580 KB Output is correct
83 Correct 88 ms 53624 KB Output is correct
84 Correct 23 ms 47444 KB Output is correct
85 Correct 23 ms 47368 KB Output is correct
86 Correct 23 ms 47444 KB Output is correct
87 Correct 23 ms 47420 KB Output is correct
88 Correct 22 ms 47444 KB Output is correct
89 Correct 23 ms 47416 KB Output is correct
90 Correct 24 ms 47476 KB Output is correct
91 Correct 23 ms 47444 KB Output is correct
92 Correct 23 ms 47492 KB Output is correct
93 Correct 22 ms 47388 KB Output is correct
94 Correct 26 ms 47316 KB Output is correct
95 Correct 22 ms 47188 KB Output is correct
96 Correct 22 ms 47240 KB Output is correct
97 Correct 22 ms 47252 KB Output is correct
98 Correct 22 ms 47316 KB Output is correct
99 Correct 22 ms 47316 KB Output is correct
100 Correct 22 ms 47280 KB Output is correct
101 Correct 22 ms 47316 KB Output is correct
102 Correct 22 ms 47308 KB Output is correct
103 Correct 22 ms 47244 KB Output is correct
104 Correct 26 ms 48296 KB Output is correct
105 Correct 33 ms 49996 KB Output is correct
106 Correct 24 ms 47224 KB Output is correct
107 Correct 41 ms 51372 KB Output is correct
108 Correct 45 ms 53068 KB Output is correct
109 Correct 22 ms 47384 KB Output is correct
110 Correct 57 ms 54572 KB Output is correct
111 Correct 63 ms 56788 KB Output is correct
112 Correct 23 ms 47280 KB Output is correct
113 Correct 81 ms 59820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 40 ms 51012 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 47384 KB Output is correct
2 Correct 22 ms 47316 KB Output is correct
3 Correct 22 ms 47188 KB Output is correct
4 Correct 21 ms 47200 KB Output is correct
5 Correct 22 ms 47280 KB Output is correct
6 Correct 22 ms 47280 KB Output is correct
7 Correct 22 ms 47188 KB Output is correct
8 Correct 21 ms 47276 KB Output is correct
9 Correct 22 ms 47236 KB Output is correct
10 Correct 21 ms 47252 KB Output is correct
11 Correct 26 ms 47204 KB Output is correct
12 Correct 23 ms 47316 KB Output is correct
13 Correct 25 ms 47292 KB Output is correct
14 Correct 22 ms 47196 KB Output is correct
15 Correct 21 ms 47264 KB Output is correct
16 Correct 23 ms 47280 KB Output is correct
17 Correct 22 ms 47288 KB Output is correct
18 Correct 22 ms 47280 KB Output is correct
19 Correct 22 ms 47188 KB Output is correct
20 Correct 21 ms 47316 KB Output is correct
21 Correct 22 ms 47244 KB Output is correct
22 Correct 23 ms 47280 KB Output is correct
23 Correct 24 ms 47188 KB Output is correct
24 Correct 22 ms 47316 KB Output is correct
25 Correct 24 ms 47288 KB Output is correct
26 Correct 22 ms 47316 KB Output is correct
27 Correct 26 ms 47408 KB Output is correct
28 Correct 24 ms 47412 KB Output is correct
29 Incorrect 23 ms 47288 KB Output isn't correct
30 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 69 ms 58596 KB Output is correct
2 Correct 61 ms 58676 KB Output is correct
3 Correct 47 ms 54716 KB Output is correct
4 Correct 28 ms 48944 KB Output is correct
5 Correct 25 ms 48200 KB Output is correct
6 Correct 32 ms 49956 KB Output is correct
7 Correct 22 ms 47292 KB Output is correct
8 Correct 43 ms 51352 KB Output is correct
9 Correct 53 ms 53124 KB Output is correct
10 Correct 21 ms 47316 KB Output is correct
11 Correct 56 ms 54604 KB Output is correct
12 Correct 67 ms 56780 KB Output is correct
13 Correct 22 ms 47384 KB Output is correct
14 Correct 24 ms 47384 KB Output is correct
15 Correct 22 ms 47316 KB Output is correct
16 Correct 22 ms 47188 KB Output is correct
17 Correct 21 ms 47200 KB Output is correct
18 Correct 22 ms 47280 KB Output is correct
19 Correct 22 ms 47280 KB Output is correct
20 Correct 22 ms 47188 KB Output is correct
21 Correct 21 ms 47276 KB Output is correct
22 Correct 22 ms 47236 KB Output is correct
23 Correct 21 ms 47252 KB Output is correct
24 Correct 26 ms 47204 KB Output is correct
25 Correct 23 ms 47316 KB Output is correct
26 Correct 25 ms 47292 KB Output is correct
27 Correct 22 ms 47196 KB Output is correct
28 Correct 21 ms 47264 KB Output is correct
29 Correct 23 ms 47280 KB Output is correct
30 Correct 22 ms 47288 KB Output is correct
31 Correct 22 ms 47280 KB Output is correct
32 Correct 22 ms 47188 KB Output is correct
33 Correct 21 ms 47316 KB Output is correct
34 Correct 22 ms 47244 KB Output is correct
35 Correct 23 ms 47280 KB Output is correct
36 Correct 24 ms 47188 KB Output is correct
37 Correct 22 ms 47316 KB Output is correct
38 Correct 24 ms 47288 KB Output is correct
39 Correct 68 ms 58772 KB Output is correct
40 Correct 77 ms 58788 KB Output is correct
41 Correct 48 ms 54776 KB Output is correct
42 Correct 28 ms 49088 KB Output is correct
43 Correct 22 ms 47288 KB Output is correct
44 Correct 22 ms 47236 KB Output is correct
45 Correct 22 ms 47276 KB Output is correct
46 Correct 23 ms 47188 KB Output is correct
47 Correct 22 ms 47316 KB Output is correct
48 Correct 21 ms 47252 KB Output is correct
49 Correct 23 ms 47316 KB Output is correct
50 Correct 23 ms 47232 KB Output is correct
51 Correct 24 ms 47256 KB Output is correct
52 Correct 23 ms 47316 KB Output is correct
53 Correct 23 ms 47280 KB Output is correct
54 Correct 22 ms 47316 KB Output is correct
55 Correct 22 ms 47224 KB Output is correct
56 Correct 21 ms 47288 KB Output is correct
57 Correct 71 ms 53796 KB Output is correct
58 Correct 75 ms 53752 KB Output is correct
59 Correct 72 ms 53668 KB Output is correct
60 Correct 69 ms 53668 KB Output is correct
61 Correct 70 ms 53636 KB Output is correct
62 Correct 78 ms 53648 KB Output is correct
63 Correct 74 ms 53452 KB Output is correct
64 Correct 71 ms 53436 KB Output is correct
65 Correct 65 ms 53440 KB Output is correct
66 Correct 69 ms 53448 KB Output is correct
67 Correct 70 ms 53672 KB Output is correct
68 Correct 68 ms 53664 KB Output is correct
69 Correct 73 ms 53656 KB Output is correct
70 Correct 71 ms 53676 KB Output is correct
71 Correct 23 ms 47304 KB Output is correct
72 Correct 23 ms 47504 KB Output is correct
73 Correct 22 ms 47468 KB Output is correct
74 Correct 23 ms 47436 KB Output is correct
75 Correct 23 ms 47420 KB Output is correct
76 Correct 27 ms 47460 KB Output is correct
77 Correct 23 ms 47444 KB Output is correct
78 Correct 23 ms 47444 KB Output is correct
79 Correct 23 ms 47460 KB Output is correct
80 Correct 74 ms 53680 KB Output is correct
81 Correct 71 ms 53700 KB Output is correct
82 Correct 76 ms 53580 KB Output is correct
83 Correct 88 ms 53624 KB Output is correct
84 Correct 23 ms 47444 KB Output is correct
85 Correct 23 ms 47368 KB Output is correct
86 Correct 23 ms 47444 KB Output is correct
87 Correct 23 ms 47420 KB Output is correct
88 Correct 22 ms 47444 KB Output is correct
89 Correct 23 ms 47416 KB Output is correct
90 Correct 24 ms 47476 KB Output is correct
91 Correct 23 ms 47444 KB Output is correct
92 Correct 23 ms 47492 KB Output is correct
93 Correct 22 ms 47388 KB Output is correct
94 Correct 26 ms 47316 KB Output is correct
95 Correct 22 ms 47188 KB Output is correct
96 Correct 22 ms 47240 KB Output is correct
97 Correct 22 ms 47252 KB Output is correct
98 Correct 22 ms 47316 KB Output is correct
99 Correct 22 ms 47316 KB Output is correct
100 Correct 22 ms 47280 KB Output is correct
101 Correct 22 ms 47316 KB Output is correct
102 Correct 22 ms 47308 KB Output is correct
103 Correct 22 ms 47244 KB Output is correct
104 Correct 26 ms 48296 KB Output is correct
105 Correct 33 ms 49996 KB Output is correct
106 Correct 24 ms 47224 KB Output is correct
107 Correct 41 ms 51372 KB Output is correct
108 Correct 45 ms 53068 KB Output is correct
109 Correct 22 ms 47384 KB Output is correct
110 Correct 57 ms 54572 KB Output is correct
111 Correct 63 ms 56788 KB Output is correct
112 Correct 23 ms 47280 KB Output is correct
113 Correct 81 ms 59820 KB Output is correct
114 Incorrect 40 ms 51012 KB Output isn't correct
115 Halted 0 ms 0 KB -