結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,380 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 3 ms
4,380 KB
testcase_08 AC 5 ms
4,560 KB
testcase_09 AC 6 ms
4,684 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 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], ww[1 << 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) {
		rep(v, n) if (!(s & 1 << v)) {
			ww[s] = ww[s | 1 << v] + w[v];
			break;
		}
		double k = (ww[s] + 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);
			}
		}
	}
	double ans = ll_inf, k = (ww[0] + 100) / 120;
	rep(i, n) ans = min(ans, dp[0][i] + k * dist(i, n));
	wt(ans + ww[0]);
}
0