답안 #230712

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
230712 2020-05-11T09:41:55 Z islingr 꿈 (IOI13_dreaming) C++14
0 / 100
160 ms 65540 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];
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);
	}
}

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 one = 0, two = 0, cmp = 0;
	rep(u, 0, n) {
		if (vis[u]) continue;
		a = u; d[u] = 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[x].eb(c[i], l);
		g[c[i]].eb(x, l);
	}
	a = 0; d[0] = 0; dfs(0); d[a] = 0; dfs(a);
	return d[a];
}

Compilation message

dreaming.cpp: In function 'int travelTime(int, int, int, int*, int*, int*)':
dreaming.cpp:39:6: warning: unused variable 'one' [-Wunused-variable]
  int one = 0, two = 0, cmp = 0;
      ^~~
dreaming.cpp:39:15: warning: unused variable 'two' [-Wunused-variable]
  int one = 0, two = 0, cmp = 0;
               ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 64 ms 12408 KB Output is correct
3 Correct 43 ms 9336 KB Output is correct
4 Correct 18 ms 4736 KB Output is correct
5 Runtime error 160 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 64 ms 12408 KB Output is correct
3 Correct 43 ms 9336 KB Output is correct
4 Correct 18 ms 4736 KB Output is correct
5 Runtime error 160 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 64 ms 12408 KB Output is correct
3 Correct 43 ms 9336 KB Output is correct
4 Correct 18 ms 4736 KB Output is correct
5 Runtime error 160 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 41 ms 8560 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 64 ms 12408 KB Output is correct
3 Correct 43 ms 9336 KB Output is correct
4 Correct 18 ms 4736 KB Output is correct
5 Runtime error 160 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 63 ms 12408 KB Output is correct
2 Correct 64 ms 12408 KB Output is correct
3 Correct 43 ms 9336 KB Output is correct
4 Correct 18 ms 4736 KB Output is correct
5 Runtime error 160 ms 65540 KB Execution killed with signal 9 (could be triggered by violating memory limits)
6 Halted 0 ms 0 KB -