Submission #334212

# Submission time Handle Problem Language Result Execution time Memory
334212 2020-12-08T16:26:25 Z LucaDantas Dreaming (IOI13_dreaming) C++17
0 / 100
59 ms 14060 KB
#include "dreaming.h"
#include<bits/stdc++.h>
using namespace std;

using pii = pair<int,int>;

#define ff first
#define ss second
#define pb push_back

constexpr int maxn = 1e5+10, inf = 0x3f3f3f3f;

vector<pii> g[maxn];
pair<pii,pii> top[maxn];
bool mark[maxn];
int ans;

int dfs(int u, int p) {
	mark[u] = 1;
	for(pii pp : g[u]) {
		int v = pp.ff, w = pp.ss;
		if(v != p) {
			int val = dfs(v, u) + w;
			if(val > top[u].ff.ff) top[u].ss = top[u].ff, top[u].ff = {val, v};
			else if(val > top[u].ss.ff) top[u].ss = {val, v};
		}
	}
	return top[u].ff.ff;
}

void dfs2(int u, int p, int up) {
	ans = min(ans, max(top[u].ff.ff, up));
	// printf("%d %d\n", u, max(top[u].ff.ff, up));
	for(pii pp : g[u]) {
		int v = pp.ff, w = pp.ss;
		if(v != p)
			dfs2(v, u,w + max(up,
				(v != top[u].ff.ss?top[u].ff.ff:top[u].ss.ff)));
	}
}

struct ANS
{
	int a, b, c;
	void upd(int x) {
		if(x > a) c = b, b = a, a = x;
		else if(x > b) c = b, b = x;
		else if(x > c) c = x;
	}
	// void db() { printf("ans %d %d %d\n", a, b, c); }
	inline int get(int x) { return max(a+b+x, b+c+2*x); }
} opa;

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
	for(int i = 0; i < M; i++)
		g[A[i]].pb({B[i], T[i]}), g[B[i]].pb({A[i], T[i]});
	for(int i = 0; i < N; i++)
		if(!mark[i])
			ans = inf, dfs(i, -1), dfs2(i, -1, 0), opa.upd(ans);
	return opa.get(L);
}
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 14060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 14060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 14060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 25 ms 7020 KB Output is correct
2 Correct 26 ms 7020 KB Output is correct
3 Correct 25 ms 7020 KB Output is correct
4 Correct 25 ms 7020 KB Output is correct
5 Correct 32 ms 7276 KB Output is correct
6 Correct 26 ms 7276 KB Output is correct
7 Correct 27 ms 7148 KB Output is correct
8 Correct 25 ms 6892 KB Output is correct
9 Correct 32 ms 6892 KB Output is correct
10 Correct 24 ms 7148 KB Output is correct
11 Correct 2 ms 2668 KB Output is correct
12 Correct 5 ms 3564 KB Output is correct
13 Correct 5 ms 3948 KB Output is correct
14 Correct 5 ms 3564 KB Output is correct
15 Correct 5 ms 3564 KB Output is correct
16 Correct 5 ms 3436 KB Output is correct
17 Correct 4 ms 3052 KB Output is correct
18 Correct 5 ms 3948 KB Output is correct
19 Correct 4 ms 3436 KB Output is correct
20 Incorrect 2 ms 2668 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 14060 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 59 ms 14060 KB Output isn't correct
2 Halted 0 ms 0 KB -