답안 #230715

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230715 2020-05-11T09:51:25 Z islingr 꿈 (IOI13_dreaming) C++14
0 / 100
63 ms 12408 KB
#include <dreaming.h>
#include <iostream>
#include <tuple>
#include <vector>
using namespace std;

#define rep(i, a, b) for (auto i = (a); i < (b); ++i)
#define trav(x, v) for (auto &x : v)

#define eb(x...) emplace_back(x)

using pii = pair<int, int>;

template<class T> bool ckmin(T& a, T b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, T b) { return a < b ? a = b, 1 : 0; }

constexpr int N = 1 << 17;
vector<pii> g[N];
int d[N], p[N], a, c[N], e[N];

void dfs(int u, int p = 0) {
	if (d[u] > d[a]) a = u;
	::p[u] = p;
	trav(e, g[u]) {
		int v, w; tie(v, w) = e;
		if (v == p) continue;
		d[v] = d[u] + w;
		dfs(v, u);
	}
}

int travelTime(int n, int m, int l, int A[], int B[], int T[]) {
	rep(i, 0, m) {
		g[A[i]].eb(B[i], T[i]);
		g[B[i]].eb(A[i], T[i]);
	}

	int cmp = 0;
	rep(u, 0, n) {
		if (!p[u]) continue;
		a = u; d[a] = 0; dfs(u); d[a] = 0; dfs(a);
		e[cmp] = d[a]; c[cmp] = a;	
		for (int v = a; p[v] != -1; v = p[v]) 
			if (ckmin(e[cmp], max(d[a] - d[v], d[v])))
				c[cmp] = v;
		++cmp;
	}

	int x = 0;
	rep(i, 0, cmp) if (e[i] > e[x]) x = i;
	rep(i, 0, cmp) {
		if (x == i) continue;
		g[c[x]].eb(c[i], l);
		g[c[i]].eb(c[x], l);
	}
	a = 1; d[a] = 0; dfs(a); d[a] = 0; dfs(a);
	return d[a];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 55 ms 12280 KB Output is correct
3 Correct 39 ms 9336 KB Output is correct
4 Correct 13 ms 4736 KB Output is correct
5 Incorrect 12 ms 4224 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 55 ms 12280 KB Output is correct
3 Correct 39 ms 9336 KB Output is correct
4 Correct 13 ms 4736 KB Output is correct
5 Incorrect 12 ms 4224 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 55 ms 12280 KB Output is correct
3 Correct 39 ms 9336 KB Output is correct
4 Correct 13 ms 4736 KB Output is correct
5 Incorrect 12 ms 4224 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 23 ms 5760 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 55 ms 12280 KB Output is correct
3 Correct 39 ms 9336 KB Output is correct
4 Correct 13 ms 4736 KB Output is correct
5 Incorrect 12 ms 4224 KB Output isn't correct
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 55 ms 12280 KB Output is correct
3 Correct 39 ms 9336 KB Output is correct
4 Correct 13 ms 4736 KB Output is correct
5 Incorrect 12 ms 4224 KB Output isn't correct
6 Halted 0 ms 0 KB -