답안 #286806

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
286806 2020-08-31T02:39:26 Z TMJN 꿈 (IOI13_dreaming) C++17
18 / 100
55 ms 12276 KB
#include "dreaming.h"
#include <bits/stdc++.h>
using namespace std;

struct edge{
	int to,dist;
};

bool vis[100000];
int D[100000];
vector<edge>E[100000];

void dfs(int x,int from){
	vis[x]=true;
	for(edge e:E[x]){
		if(e.to==from)continue;
		dfs(e.to,x);
		D[x]=max(D[x],D[e.to]+e.dist);
	}
}

int travelTime(int N, int M, int L, int a[], int b[], int d[]) {
	for(int i=0;i<M;i++){
		E[a[i]].push_back({b[i],d[i]});
		E[b[i]].push_back({a[i],d[i]});
	}
	vector<int>v;
	for(int i=0;i<N;i++){
		if(!vis[i]){
			dfs(i,i);
			int p=i;
			int from=i;
			int m=0;
			int mn=D[i];
			while(true){
				pair<int,int>mx={-1,-1};
				for(edge e:E[p]){
					if(e.to==from)continue;
					mx=max(mx,{D[e.to],e.to});
				}
				if(mx==pair<int,int>{-1,-1})break;
				for(edge e:E[p]){
					if(e.to==from||e.to==mx.second)continue;
					m=max(m,D[e.to]+e.to);
				}
				mn=min(mn,max(m,D[p]));
				for(edge e:E[p]){
					if(e.to==mx.second)m+=e.dist;
				}
				from=p;
				p=mx.second;
			}
			v.push_back(mn);
		}
	}
	sort(v.begin(),v.end(),greater<>());
	if(v.size()==1){
		return v.front();
	}
	else if(v.size()==2){
		return v.front()+v.back()+L;
	}
	else{
		return max(v[0]+v[1]+L,v[1]+v[2]+L+L);
	}
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 12276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 12276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 12276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 6272 KB Output is correct
2 Correct 25 ms 6264 KB Output is correct
3 Correct 25 ms 6272 KB Output is correct
4 Correct 26 ms 6264 KB Output is correct
5 Correct 25 ms 6196 KB Output is correct
6 Correct 28 ms 6784 KB Output is correct
7 Correct 28 ms 6392 KB Output is correct
8 Correct 25 ms 6264 KB Output is correct
9 Correct 27 ms 6132 KB Output is correct
10 Correct 26 ms 6372 KB Output is correct
11 Correct 2 ms 2688 KB Output is correct
12 Correct 5 ms 3708 KB Output is correct
13 Correct 6 ms 3708 KB Output is correct
14 Correct 5 ms 3708 KB Output is correct
15 Correct 5 ms 3708 KB Output is correct
16 Correct 5 ms 3708 KB Output is correct
17 Correct 5 ms 3580 KB Output is correct
18 Correct 6 ms 3708 KB Output is correct
19 Correct 5 ms 3708 KB Output is correct
20 Correct 2 ms 2688 KB Output is correct
21 Correct 2 ms 2688 KB Output is correct
22 Correct 2 ms 2688 KB Output is correct
23 Correct 6 ms 3708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 12276 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 12276 KB Output isn't correct
2 Halted 0 ms 0 KB -