Submission #403630

# Submission time Handle Problem Language Result Execution time Memory
403630 2021-05-13T10:26:11 Z ritul_kr_singh Dreaming (IOI13_dreaming) C++17
0 / 100
52 ms 11156 KB
#include <bits/stdc++.h>
using namespace std;
#define sp << ' ' <<
#define nl << '\n'
#include "dreaming.h"

const int MAXN = 1e5, INF = 2e9;

vector<array<int, 2>> g[MAXN];
int a[MAXN], b, x, y;
bitset<MAXN> vis;

void dfs(int u, int d, int p = -1){
	vis[u] = 1;
	a[u] = max(a[u], d);
	if(d > x) x = d, y = u;
	if(d < 0) b = min(b, a[u]);
	for(auto &e : g[u]) if(e[0] != p) dfs(e[0], d < 0 ? d : d + e[1], u);
}

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]});
	}
	priority_queue<int> q;
	for(int i=0; i<n; ++i){
		if(vis[i]) continue;
		x = y = -1, b = INF;
		dfs(i, 0), dfs(y, 0), dfs(y, 0);
		dfs(i, -1);
		q.push(-b);
		while(q.size() > 3) q.pop();
	}
	int a3 = -q.top(); q.pop();
	int a2 = -q.top(); q.pop();
	int a1 = -q.top(); q.pop();
	return max(a1 + a2 + L, a2 + a3 + L + L);
}
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 11156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 11156 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 24 ms 5320 KB Output is correct
2 Correct 24 ms 5368 KB Output is correct
3 Correct 22 ms 5348 KB Output is correct
4 Correct 24 ms 5340 KB Output is correct
5 Correct 22 ms 5324 KB Output is correct
6 Correct 23 ms 5452 KB Output is correct
7 Correct 24 ms 5520 KB Output is correct
8 Correct 23 ms 5196 KB Output is correct
9 Correct 22 ms 5220 KB Output is correct
10 Correct 31 ms 5384 KB Output is correct
11 Correct 2 ms 2636 KB Output is correct
12 Correct 6 ms 3020 KB Output is correct
13 Correct 7 ms 3076 KB Output is correct
14 Correct 6 ms 3020 KB Output is correct
15 Correct 7 ms 3072 KB Output is correct
16 Correct 7 ms 2964 KB Output is correct
17 Correct 6 ms 3020 KB Output is correct
18 Correct 6 ms 3020 KB Output is correct
19 Correct 6 ms 3020 KB Output is correct
20 Incorrect 2 ms 2636 KB Output isn't correct
21 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 2636 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 52 ms 11156 KB Output isn't correct
2 Halted 0 ms 0 KB -