답안 #230708

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230708 2020-05-11T09:24:45 Z islingr 꿈 (IOI13_dreaming) C++14
컴파일 오류
0 ms 0 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<long long, long long>;

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 long long N = 1 << 17;
vector<pii> g[N];
long long d[N], p[N], a;
bool vis[N];

void dfs(long long u, long long p = -1) {
	if (d[u] > d[a]) a = u;
	::p[u] = p;
	vis[u] = true;
	trav(e, g[u]) {
		long long v, w; tie(v, w) = e;
		if (v == p) continue;
		d[v] = d[u] + w;
		dfs(v, u);
	}
}

int travelTime(long long n, long long m, long long l, long long A[], long long B[], long long T[]) {
	rep(i, 0, m) {
		g[A[i]].eb(B[i], T[i]);
		g[B[i]].eb(A[i], T[i]);
	}
	long long ans = 0, one = 0, two = 0;
	rep(u, 0, n) {
		if (vis[u]) continue;
		a = u; d[u] = 0; dfs(u);
		d[a] = 0; dfs(a);
		long long e = d[a]; ckmax(ans, d[a]);
		for (long long v = a; p[v] != -1; v = p[v]) 
			ckmin(e, max(d[a] - d[v], d[v]));
		if (one <= e) two = one, one = e;
		else if (two < e) two = e;
	}
	return two ? max(ans, one + two + l) : ans;
}

Compilation message

/tmp/cc33T1Cp.o: In function `main':
grader.c:(.text.startup+0xa2): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status