Submission #297978

# Submission time Handle Problem Language Result Execution time Memory
297978 2020-09-12T08:58:33 Z Hemimor Dreaming (IOI13_dreaming) C++14
18 / 100
67 ms 15096 KB
#include "dreaming.h"
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <cassert>
#include <vector>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<P,int> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-8;
const ll mod=1e9+7;
const int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int n;
vvp g;
vi b;

P dfs(int v,int pr=-1,int d=0){
	b[v]=d;
	P tmp={d,v};
	for(auto p:g[v]){
		int u=p.first;
		if(u!=pr) tmp=max(tmp,dfs(u,v,d+p.second));
	}
	return tmp;
}

int DFS(int v,int pr=-1,int d=0){
	int tmp=max(d,b[v]);
	for(auto p:g[v]){
		int u=p.first;
		if(u!=pr) tmp=min(tmp,DFS(u,v,d+p.second));
	}
	return tmp;
}

int f(int v){
	v=dfs(v).second;
	int u=dfs(v).second;
	return DFS(u);
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	n=N;
	g=vvp(n);
	b=vi(n,-1);
	for(int i=0;i<M;i++){
		int u=A[i],v=B[i];
		g[u].push_back({v,T[i]});
		g[v].push_back({u,T[i]});
	}
	vi a;
	for(int i=0;i<n;i++) if(b[i]<0) a.push_back(f(i));
	sort(a.rbegin(),a.rend());
	int m=a.size();
	if(m==1) return a[0];
	if(m==2) return a[0]+a[1]+L;
	int res=inf;
	res=min(res,max(a[0]+a[1],a[1]+a[2]+L)+L);
	res=min(res,max(a[1]+a[0],a[0]+a[2]+L)+L);
	res=min(res,max(a[2]+a[0],a[0]+a[1]+L)+L);
	return res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 15096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 15096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 15096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 41 ms 6008 KB Output is correct
2 Correct 29 ms 6016 KB Output is correct
3 Correct 29 ms 6008 KB Output is correct
4 Correct 32 ms 6008 KB Output is correct
5 Correct 29 ms 6016 KB Output is correct
6 Correct 31 ms 6648 KB Output is correct
7 Correct 31 ms 6272 KB Output is correct
8 Correct 29 ms 5888 KB Output is correct
9 Correct 30 ms 5880 KB Output is correct
10 Correct 30 ms 6264 KB Output is correct
11 Correct 1 ms 384 KB Output is correct
12 Correct 7 ms 3708 KB Output is correct
13 Correct 7 ms 3708 KB Output is correct
14 Correct 7 ms 3708 KB Output is correct
15 Correct 8 ms 3708 KB Output is correct
16 Correct 7 ms 3708 KB Output is correct
17 Correct 7 ms 3708 KB Output is correct
18 Correct 8 ms 3836 KB Output is correct
19 Correct 11 ms 3708 KB Output is correct
20 Correct 0 ms 384 KB Output is correct
21 Correct 1 ms 384 KB Output is correct
22 Correct 1 ms 384 KB Output is correct
23 Correct 7 ms 3708 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 15096 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 67 ms 15096 KB Output isn't correct
2 Halted 0 ms 0 KB -