답안 #330332

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
330332 2020-11-24T19:37:05 Z zggf 꿈 (IOI13_dreaming) C++14
18 / 100
52 ms 12268 KB
#include "dreaming.h"
#include <bits/stdc++.h>

using namespace std;

vector<vector<pair<int, int>>> graf;
vector<bool> odw, odw2;

vector<int> tab, dlg1, dlg2;

void dfs(int x){
	odw[x] = true;
	dlg1[x] = 0;	
	dlg2[x] = 0;	
	for(auto it:graf[x]){
		if(!odw[it.first]){
			dfs(it.first);
			int tmp = it.second+dlg1[it.first];
			if(tmp>dlg2[x]){
				if(tmp>dlg1[x]){
					dlg2[x]=dlg1[x];
					dlg1[x] = tmp;	
				}else{
					dlg2[x] = tmp;	
				}
			}	
		}	
	}
}

int dfs2(int x, int gor = 0){
	odw2[x] = true;
	int out = 1e9;
	for(auto it:graf[x]){
		if(!odw2[it.first]){
			if(dlg1[it.first]+it.second!=dlg1[x]) out = min(out, dfs2(it.first, max(gor, dlg1[x])+it.second));		
			else out = min(out, dfs2(it.first, max(gor, dlg2[x])+it.second));
		}		
	}
	int cur = dlg1[x];
	cur = max(cur, gor);
	out = min(out, cur);
	return out;
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	odw.resize(N);
	odw2.resize(N);
	graf.resize(N);
	dlg1.resize(N);
	dlg2.resize(N);
	for(int i = 0; i < M; i++){
		graf[A[i]].push_back(make_pair(B[i], T[i]));	
		graf[B[i]].push_back(make_pair(A[i], T[i]));	
	}	
	for(int i = 0; i < N; i++){
		if(!odw[i]){
			dfs(i);
			tab.push_back(dfs2(i));
		}	
	}
	sort(tab.begin(), tab.end());
	if(tab.size()==1) return tab.back();
	if(tab.size()==2) return tab[0]+tab[1]+L;
	return max(tab.back()+L+tab[tab.size()-2], tab[tab.size()-2]+tab[tab.size()-3]+2*L);
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 12268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 12268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 12268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 6384 KB Output is correct
2 Correct 33 ms 6496 KB Output is correct
3 Correct 26 ms 6384 KB Output is correct
4 Correct 32 ms 6380 KB Output is correct
5 Correct 31 ms 6396 KB Output is correct
6 Correct 28 ms 7024 KB Output is correct
7 Correct 27 ms 6640 KB Output is correct
8 Correct 25 ms 6252 KB Output is correct
9 Correct 25 ms 6256 KB Output is correct
10 Correct 27 ms 6764 KB Output is correct
11 Correct 1 ms 364 KB Output is correct
12 Correct 6 ms 4200 KB Output is correct
13 Correct 6 ms 4200 KB Output is correct
14 Correct 6 ms 4200 KB Output is correct
15 Correct 6 ms 4200 KB Output is correct
16 Correct 6 ms 4200 KB Output is correct
17 Correct 6 ms 4072 KB Output is correct
18 Correct 6 ms 4208 KB Output is correct
19 Correct 6 ms 4200 KB Output is correct
20 Correct 1 ms 364 KB Output is correct
21 Correct 1 ms 492 KB Output is correct
22 Correct 1 ms 492 KB Output is correct
23 Correct 6 ms 4200 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 12268 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 52 ms 12268 KB Output isn't correct
2 Halted 0 ms 0 KB -