답안 #338761

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
338761 2020-12-23T20:55:49 Z wind_reaper 꿈 (IOI13_dreaming) C++17
0 / 100
55 ms 14316 KB
#include "dreaming.h"
#include <bits/stdc++.h>
 
using namespace std; 

const int MAXN = 1e5 + 5, INF = INT_MAX;  	
pair<int, int> root, leaf[2]; 
vector<pair<int, int>> adj[MAXN];
int ddist[MAXN][2]; 
bool vis[MAXN]; 
int comps[MAXN]; 
void dfs(int node, int p, int dist, int idx){
	vis[node] = 1; 
	leaf[idx] = max(leaf[idx], {dist, node}); 
	ddist[node][idx] = dist; 

	root = min(root, {max(ddist[node][0], ddist[node][1]), node}); 

	for(auto& [v, wt] : adj[node]){
		if(v == p) 
			continue; 

		dfs(v, node, dist + wt, idx); 
	}
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	for(int i = 0; i < M; i++){
		adj[A[i]].emplace_back(make_pair(B[i], T[i])); 
		adj[B[i]].emplace_back(make_pair(A[i], T[i])); 
	}
	int c = 0; 
	for(int i = 0; i < N; i++){
		if(vis[i] == 1) 
			continue; 

		leaf[0] = leaf[1] = {INT_MIN, INT_MIN}; 

		dfs(i, i, 0, 0); 
		dfs(leaf[0].second, -1, 0, 1); 
		root = {INF, i}; 
		dfs(leaf[1].second, -1, 0, 0);
		comps[c++] = root.first; 
	}

	sort(comps, comps + c); 
	return max({comps[c-1] + comps[c-2] + L, comps[c-2] + comps[c-3] + 2*L}); 
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 14316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 14316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 14316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 30 ms 6508 KB Output is correct
2 Correct 28 ms 6508 KB Output is correct
3 Correct 25 ms 6508 KB Output is correct
4 Correct 27 ms 6528 KB Output is correct
5 Correct 25 ms 6520 KB Output is correct
6 Correct 27 ms 6764 KB Output is correct
7 Correct 31 ms 6636 KB Output is correct
8 Correct 28 ms 6380 KB Output is correct
9 Correct 25 ms 6380 KB Output is correct
10 Correct 29 ms 6636 KB Output is correct
11 Correct 2 ms 2796 KB Output is correct
12 Correct 7 ms 3948 KB Output is correct
13 Correct 8 ms 4076 KB Output is correct
14 Correct 7 ms 3948 KB Output is correct
15 Correct 7 ms 3948 KB Output is correct
16 Correct 7 ms 3948 KB Output is correct
17 Correct 7 ms 3948 KB Output is correct
18 Correct 8 ms 4076 KB Output is correct
19 Correct 8 ms 3968 KB Output is correct
20 Incorrect 2 ms 2668 KB Output isn't correct
21 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 14316 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 14316 KB Output isn't correct
2 Halted 0 ms 0 KB -