답안 #763994

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
763994 2023-06-23T05:00:26 Z NothingXD 꿈 (IOI13_dreaming) C++17
18 / 100
37 ms 15196 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;

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;
			}
			dfs(q1, h[1]);
			int q2 = i;
			for (auto x: going){
				if (h[1][x] > h[1][q2]) q2 = x;
			}
			dfs(q2, h[0]);
			int ans = maxn;
			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 15196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 15196 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 15 ms 6104 KB Output is correct
2 Correct 16 ms 6100 KB Output is correct
3 Correct 19 ms 6192 KB Output is correct
4 Correct 15 ms 6168 KB Output is correct
5 Correct 15 ms 6100 KB Output is correct
6 Correct 17 ms 6652 KB Output is correct
7 Correct 16 ms 6236 KB Output is correct
8 Correct 15 ms 6104 KB Output is correct
9 Correct 15 ms 6096 KB Output is correct
10 Correct 17 ms 6224 KB Output is correct
11 Correct 2 ms 2644 KB Output is correct
12 Correct 5 ms 3968 KB Output is correct
13 Correct 6 ms 4048 KB Output is correct
14 Correct 5 ms 3920 KB Output is correct
15 Correct 5 ms 3920 KB Output is correct
16 Correct 5 ms 3920 KB Output is correct
17 Correct 5 ms 3536 KB Output is correct
18 Correct 6 ms 4048 KB Output is correct
19 Correct 5 ms 3920 KB Output is correct
20 Correct 1 ms 2644 KB Output is correct
21 Correct 1 ms 2644 KB Output is correct
22 Correct 2 ms 2644 KB Output is correct
23 Correct 5 ms 3920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 37 ms 15196 KB Output isn't correct
2 Halted 0 ms 0 KB -