Submission #81470

# Submission time Handle Problem Language Result Execution time Memory
81470 2018-10-24T20:29:15 Z farukkastamonuda Dreaming (IOI13_dreaming) C++14
0 / 100
76 ms 12028 KB
#include "dreaming.h"
#include <bits/stdc++.h>
#define fi first
#define se second
#define lo long long 
#define inf 1000000009
#define md 1000000007
#define li 100005
#define mp make_pair
#define pb push_back
using namespace std;
int x=-inf,xx=-inf,xxx=-inf,vis[li],mn,M[li],M2[li],node[li],ss,m;
vector< pair<int,int> > v[li];
void f(int x){
	vis[x]=1;
	int t;
	for(int i=0;i<(int)v[x].size();i++){
		int go=v[x][i].fi;
		int knr=v[x][i].se;
		if(vis[go]==1) continue;
		f(go);
		t=M[go]+knr;
		if(M[x]<t){
			M2[x]=M[x];
			M[x]=t;
			node[x]=go;
		}
		else if(M2[x]<t){
			M2[x]=t;
		}
	}
	ss=max(ss,M[x]+M2[x]);
}
void g(int x,int p,int t){
	mn=min(mn,max(M[x],t));
	for(int i=0;i<(int)v[x].size();i++){
		int go=v[x][i].fi;
		int knr=v[x][i].se;
		if(go==p) continue;
		int a=max(t,node[x]==go?M2[x]:M[x]);
		g(go,x,a+knr);
	}
}
int travelTime(int n,int m,int l,int A[],int B[],int T[]){
	for(int i=0;i<m;i++){
		v[A[i]].pb(mp(B[i],T[i]));
		v[B[i]].pb(mp(A[i],T[i]));
	}
	for(int i=0;i<n;i++){
		if(vis[i]==1) continue;
		mn=inf;
		f(i);
		g(i,-1,0);
		if(x<mn){
			x=mn;
			xx=x;
			xxx=xx;
		}
		else if(xx<mn){
			xx=mn;
			xxx=xx;
		}
		else if(xxx<mn){
			xxx=mn;
		}
	}
	return max(ss,max(x+xx+l,xx+xxx+l+l));
}
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 12028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 12028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 12028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 6528 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 12028 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 76 ms 12028 KB Output isn't correct
2 Halted 0 ms 0 KB -