結果

問題 No.134 走れ!サブロー君
ユーザー yuruhiyayuruhiya
提出日時 2020-08-18 15:19:56
言語 cLay
(20240104-1)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 729 bytes
コンパイル時間 2,259 ms
コンパイル使用メモリ 165,464 KB
実行使用メモリ 4,500 KB
最終ジャッジ日時 2023-09-19 01:01:34
合計ジャッジ時間 3,121 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 3 ms
4,376 KB
testcase_07 AC 4 ms
4,376 KB
testcase_08 AC 7 ms
4,496 KB
testcase_09 AC 7 ms
4,500 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

int n, m, x[14], y[14], p, q;
double w[13], dp[1 << 13][13];
double dist(int i, int j) {
	return abs(x[i] - x[j]) + abs(y[i] - y[j]);
}
double calc(int i, int j, double weight) {
	return (weight + 100.0) / 120.0 * dist(i, j);
}
{
	rd(p, q, n, (x, y, w)(n));
	x[n] = p;
	y[n] = q;
	m = 1 << n;
	rep(i, m) rep(j, n) dp[i][j] = ll_inf;
	rep(v, n) dp[m - 1][v] = dist(v, n) * 5.0 / 6;
	rrep(s, m - 1) {
		double k = 0;
		rep(v, n) if (!(s & 1 << v)) k += w[v];
		k = (k + 100) / 120;
		rep(v, n) rep(u, n) {
			if (!(s & 1 << u)) {
				dp[s][v] = min(dp[s][v], dp[s | 1 << u][u] + dist(v, u) * k + w[u]);
			}
		}
	}
	double ans = ll_inf, k = (sum(w(n)) + 100) / 120;
	rep(i, n) ans = min(ans, dp[0][i] + k * dist(i, n));
	wt(ans);
}
0