Submission #31785

# Submission time Handle Problem Language Result Execution time Memory
31785 2017-09-09T03:28:21 Z Diuven Dreaming (IOI13_dreaming) C++11
18 / 100
117 ms 15592 KB
#include <bits/stdc++.h>
#include "dreaming.h"
using namespace std;
typedef struct {int to, cost;} edge;
vector<edge> G[100010], T(100010);
vector<int> rad;
bool done[100010];
int N, M, L, tmp, sz[100010], u, D;
int find(int v, bool trace=false, int p=-1, int d=0){
	done[v]=true;
	if(tmp<d)	tmp=d, u=v;
	int mx=0;
	for(auto& e:G[v]){
		if(e.to==p)	continue;
		int down=find(e.to, false, v, d+e.cost)+e.cost;
		if(down>mx)	mx=down, T[v]=e;
	}
	return mx;
}
int findcen(int v){
	tmp=-1, find(v); int a=u;
	tmp=-1, T.clear(), find(a,true); int b=u, dia=tmp, now=0;
	while(a!=b){
		int nxt=now+T[a].cost;
		if(nxt<=dia-nxt){
			a=T[a].to, now=nxt;	continue;
		}
		if(max(now, dia-now)>max(nxt, dia-nxt))
			a=T[a].to;
		break;
	}
	return a;
}
int travelTime(int N, int M, int L, int A[], int B[], int T[]){
	for(int i=1; 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=-1, find(c), rad.push_back(tmp);
			tmp=-1, 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;
}
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 15592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 15592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 15592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 30 ms 6264 KB Output is correct
2 Correct 38 ms 6268 KB Output is correct
3 Correct 39 ms 6380 KB Output is correct
4 Correct 37 ms 6356 KB Output is correct
5 Correct 31 ms 6264 KB Output is correct
6 Correct 33 ms 6648 KB Output is correct
7 Correct 28 ms 6400 KB Output is correct
8 Correct 33 ms 6272 KB Output is correct
9 Correct 27 ms 6264 KB Output is correct
10 Correct 29 ms 6400 KB Output is correct
11 Correct 5 ms 3456 KB Output is correct
12 Correct 8 ms 4220 KB Output is correct
13 Correct 9 ms 4220 KB Output is correct
14 Correct 8 ms 4220 KB Output is correct
15 Correct 8 ms 4220 KB Output is correct
16 Correct 9 ms 4220 KB Output is correct
17 Correct 8 ms 4220 KB Output is correct
18 Correct 8 ms 4220 KB Output is correct
19 Correct 8 ms 4220 KB Output is correct
20 Correct 4 ms 3456 KB Output is correct
21 Correct 5 ms 3456 KB Output is correct
22 Correct 5 ms 3556 KB Output is correct
23 Correct 8 ms 4220 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 15592 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 117 ms 15592 KB Output isn't correct
2 Halted 0 ms 0 KB -