답안 #31789

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
31789 2017-09-09T03:34:01 Z Diuven 꿈 (IOI13_dreaming) C++11
18 / 100
65 ms 11384 KB
#include <bits/stdc++.h>
#include "dreaming.h"
using namespace std;
typedef struct {int to, cost;} edge;
vector<edge> G[100010];
vector<int> rad;
bool done[100010];
int N, M, L, tmp, sz[100010], u, D;
int dfs(int v){
	done[v]=true, sz[v]=1;
	for(auto& e:G[v])
		if(!done[e.to])	sz[v]+=dfs(e.to);
	return sz[v];
}
int findcen(int v){
	dfs(v);
	int now=v;
	bool iscen=false;
	while(!iscen){
		iscen=true;
		for(auto& e:G[now])
			if(sz[now]>sz[e.to]&&sz[e.to]>sz[v]/2){
				iscen=false, now=e.to;
				break;
			}
	}
	return now;
}
void find(int v, int p=-1, int d=0){
	if(tmp<=d)	tmp=d, u=v;
	for(auto& e:G[v])
		if(e.to!=p)	find(e.to, v, d+e.cost);
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]){
	for(int i=0; i<M; i++){
		G[A[i]+1].push_back({B[i]+1, T[i]});
		G[B[i]+1].push_back({A[i]+1, T[i]});
	}
	for(int i=1; i<=N; i++)
		if(!done[i]){
			int c=findcen(i);
			tmp=0, find(c), rad.push_back(tmp);
			tmp=0, find(u), D=max(D, tmp);
		}
	sort(rad.begin(), rad.end(), greater<int>());
	if(rad.size()>1U)	D=max(D, rad[0]+rad[1]+L);
	if(rad.size()>2U)	D=max(D, rad[1]+rad[2]+2*L);
	return D;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 11384 KB Output is correct
2 Correct 65 ms 11284 KB Output is correct
3 Correct 43 ms 8312 KB Output is correct
4 Correct 11 ms 3968 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4608 KB Output is correct
7 Incorrect 4 ms 2688 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 11384 KB Output is correct
2 Correct 65 ms 11284 KB Output is correct
3 Correct 43 ms 8312 KB Output is correct
4 Correct 11 ms 3968 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4608 KB Output is correct
7 Incorrect 4 ms 2688 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 11384 KB Output is correct
2 Correct 65 ms 11284 KB Output is correct
3 Correct 43 ms 8312 KB Output is correct
4 Correct 11 ms 3968 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4608 KB Output is correct
7 Incorrect 4 ms 2688 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 35 ms 5872 KB Output is correct
2 Correct 27 ms 5880 KB Output is correct
3 Correct 28 ms 5904 KB Output is correct
4 Correct 27 ms 5880 KB Output is correct
5 Correct 30 ms 6008 KB Output is correct
6 Correct 33 ms 6264 KB Output is correct
7 Correct 25 ms 6016 KB Output is correct
8 Correct 31 ms 5888 KB Output is correct
9 Correct 26 ms 5752 KB Output is correct
10 Correct 26 ms 5880 KB Output is correct
11 Correct 3 ms 2688 KB Output is correct
12 Correct 7 ms 3836 KB Output is correct
13 Correct 8 ms 3836 KB Output is correct
14 Correct 7 ms 3836 KB Output is correct
15 Correct 7 ms 3836 KB Output is correct
16 Correct 7 ms 3836 KB Output is correct
17 Correct 7 ms 3708 KB Output is correct
18 Correct 8 ms 3964 KB Output is correct
19 Correct 7 ms 3836 KB Output is correct
20 Correct 3 ms 2688 KB Output is correct
21 Correct 3 ms 2688 KB Output is correct
22 Correct 4 ms 2816 KB Output is correct
23 Correct 7 ms 3836 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 11384 KB Output is correct
2 Correct 65 ms 11284 KB Output is correct
3 Correct 43 ms 8312 KB Output is correct
4 Correct 11 ms 3968 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4608 KB Output is correct
7 Incorrect 4 ms 2688 KB Output isn't correct
8 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 65 ms 11384 KB Output is correct
2 Correct 65 ms 11284 KB Output is correct
3 Correct 43 ms 8312 KB Output is correct
4 Correct 11 ms 3968 KB Output is correct
5 Correct 10 ms 3456 KB Output is correct
6 Correct 18 ms 4608 KB Output is correct
7 Incorrect 4 ms 2688 KB Output isn't correct
8 Halted 0 ms 0 KB -