Submission #96748

# Submission time Handle Problem Language Result Execution time Memory
96748 2019-02-11T17:21:11 Z figter001 Dreaming (IOI13_dreaming) C++14
14 / 100
97 ms 10232 KB
#include "dreaming.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
const int maxn = 1e5;

vector<pair<int,int>> g[maxn];
vector<int> C;
int mx,to,cst[maxn],t,best,mn,vis[maxn],c;

void path(int u,int cost){
	vis[u] = c;
	if(cost > mx){
		mx = cost;
		to = u;
	}
	for(pair<int,int> cur : g[u]){
		int v = cur.first;
		int w = cur.second;
		if(vis[v] == c)continue;
		path(v,cost + w);
	}
}

void dfs(int u,int cost){
	vis[u] = c;
	if(t == 1){
		cst[u] = max(cst[u],cost);
		if(cst[u] < mn){
			mn = cst[u];
			best = u;
		}
	}else cst[u] = cost;
	for(pair<int,int> cur : g[u]){
		int v = cur.first;
		int w = cur.second;
		if(vis[v] == c)continue;
		dfs(v,cost + w);
	}	
}

void find(int s){
	mn = 2e9;
	mx = 0;
	c++;
	path(s,0);
	int a = to;
	c++;
	mx = 0;
	path(a,0);
	int b = to;
	t = 0;
	c++;
	dfs(a,0);
	t = 1;
	c++;
	dfs(b,0);
	C.push_back(best);
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	for(int i=0;i<M;i++){
		g[A[i]].push_back({B[i],T[i]});
		g[B[i]].push_back({A[i],T[i]});
	}
	for(int i=0;i<N;i++)
		if(!vis[i])
			find(i);
	for(int i=1;i<C.size();i++){
		g[C[i]].push_back({C[0],L});
		g[C[0]].push_back({C[i],L});
	}
	c++;
	mx = 0;
	path(0,0);
	c++;
	mx = 0;
	path(to,0);
    return mx;
}

Compilation message

grader.c: In function 'int main()':
grader.c:18:6: warning: variable 'res' set but not used [-Wunused-but-set-variable]
  int res;
      ^~~
dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:71:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=1;i<C.size();i++){
              ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 62 ms 10220 KB Output is correct
2 Correct 64 ms 10232 KB Output is correct
3 Correct 43 ms 7552 KB Output is correct
4 Correct 12 ms 3836 KB Output is correct
5 Correct 11 ms 3320 KB Output is correct
6 Correct 23 ms 4344 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 39 ms 5496 KB Output is correct
9 Correct 48 ms 6464 KB Output is correct
10 Correct 5 ms 2808 KB Output is correct
11 Correct 83 ms 7800 KB Output is correct
12 Correct 79 ms 8944 KB Output is correct
13 Correct 5 ms 2808 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2684 KB Output is correct
2 Correct 4 ms 2680 KB Output is correct
3 Correct 5 ms 2680 KB Output is correct
4 Correct 4 ms 2680 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2680 KB Output is correct
8 Correct 4 ms 2684 KB Output is correct
9 Correct 4 ms 2680 KB Output is correct
10 Correct 5 ms 2680 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 5 ms 2680 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Incorrect 4 ms 2680 KB Output isn't correct
16 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 79 ms 10232 KB Output is correct
2 Correct 71 ms 10132 KB Output is correct
3 Correct 43 ms 7544 KB Output is correct
4 Correct 12 ms 3704 KB Output is correct
5 Correct 4 ms 2680 KB Output is correct
6 Correct 4 ms 2680 KB Output is correct
7 Correct 4 ms 2652 KB Output is correct
8 Correct 4 ms 2680 KB Output is correct
9 Correct 3 ms 2680 KB Output is correct
10 Correct 5 ms 2684 KB Output is correct
11 Correct 4 ms 2680 KB Output is correct
12 Correct 4 ms 2808 KB Output is correct
13 Correct 4 ms 2680 KB Output is correct
14 Correct 4 ms 2680 KB Output is correct
15 Correct 4 ms 2680 KB Output is correct
16 Correct 5 ms 2680 KB Output is correct
17 Correct 4 ms 2680 KB Output is correct
18 Correct 4 ms 2680 KB Output is correct
19 Correct 85 ms 8568 KB Output is correct
20 Correct 92 ms 8568 KB Output is correct
21 Correct 89 ms 8568 KB Output is correct
22 Correct 96 ms 8440 KB Output is correct
23 Correct 89 ms 8440 KB Output is correct
24 Correct 83 ms 8440 KB Output is correct
25 Correct 84 ms 8312 KB Output is correct
26 Incorrect 97 ms 8312 KB Output isn't correct
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 56 ms 6936 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 5 ms 2808 KB Output is correct
3 Correct 5 ms 2808 KB Output is correct
4 Incorrect 4 ms 2680 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 4 ms 2680 KB Output is correct
2 Correct 6 ms 2808 KB Output is correct
3 Correct 5 ms 2936 KB Output is correct
4 Correct 52 ms 7384 KB Output is correct
5 Correct 71 ms 8536 KB Output is correct
6 Incorrect 5 ms 2808 KB Output isn't correct
7 Halted 0 ms 0 KB -