답안 #230707

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230707 2020-05-11T09:23:59 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<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; }

#define int long long

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

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

signed 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 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);
		int e = d[a]; ckmax(ans, d[a]);
		for (int 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/ccn9dGnz.o: In function `main':
grader.c:(.text.startup+0xa2): undefined reference to `travelTime'
collect2: error: ld returned 1 exit status