답안 #764001

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
764001 2023-06-23T05:18:25 Z NothingXD 꿈 (IOI13_dreaming) C++17
18 / 100
37 ms 13540 KB
#include "dreaming.h"
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef complex<ld> point;

void debug_out(){cerr << endl;}

template<typename Head, typename... Tail>
void debug_out(Head H, Tail... T){
	cout << H << ' ';
	debug_out(T...);
}

#define debug(...) cerr << "(" << #__VA_ARGS__ << "): ", debug_out(__VA_ARGS__)
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define MP(x, y) make_pair(x, y)

const int maxn = 1e5 + 10;
const int inf = 1e9;

int n, m, l, h[2][maxn];
vector<pii> g[maxn];
vector<int> going, res;
bool vis[maxn];

void dfs(int v, int *h, int p = -1){
	vis[v] = true;
	going.push_back(v);
	for (auto [u, w]: g[v]){
		if (u != p){
			h[u] = h[v] + w;
			dfs(u, h, v);
		}
	}
}

int travelTime(int N, int M, int L, int A[], int B[], int T[]) {
    n = N, m = M, l = L;
	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]){
			going.clear();
			dfs(i, h[0]);
			int q1 = i;
			for (auto x: going){
				if (h[0][x] > h[0][q1]) q1 = x;
			}
			going.clear();
			dfs(q1, h[1]);
			int q2 = i;
			for (auto x: going){
				if (h[1][x] > h[1][q2]) q2 = x;
			}
			going.clear();
			h[0][q2] = 0;
			dfs(q2, h[0]);
			int ans = inf;
			for (auto x: going){
				ans = min(ans, max(h[0][x], h[1][x]));
			}
			res.push_back(ans);
		}
	}
	sort(all(res), greater<int>());
	int ans = 0;
	ans = max(ans, res[0]);
	if (res.size() >= 2) ans = max(ans, res[0] + res[1] + l);
	if (res.size() >= 3) ans = max(ans, res[1] + res[2] + 2 * l);
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 13540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 13540 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 23 ms 6188 KB Output is correct
2 Correct 14 ms 6100 KB Output is correct
3 Correct 14 ms 6184 KB Output is correct
4 Correct 17 ms 6152 KB Output is correct
5 Correct 14 ms 6100 KB Output is correct
6 Correct 17 ms 6540 KB Output is correct
7 Correct 19 ms 6404 KB Output is correct
8 Correct 22 ms 6084 KB Output is correct
9 Correct 14 ms 6096 KB Output is correct
10 Correct 18 ms 6224 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 5 ms 4080 KB Output is correct
13 Correct 5 ms 4084 KB Output is correct
14 Correct 6 ms 4048 KB Output is correct
15 Correct 5 ms 4048 KB Output is correct
16 Correct 5 ms 4048 KB Output is correct
17 Correct 6 ms 3792 KB Output is correct
18 Correct 7 ms 4048 KB Output is correct
19 Correct 5 ms 4048 KB Output is correct
20 Correct 2 ms 2644 KB Output is correct
21 Correct 2 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 5 ms 4048 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 13540 KB Output isn't correct
2 Halted 0 ms 0 KB -