結果

問題 No.134 走れ!サブロー君
ユーザー takune1024takune1024
提出日時 2017-12-01 01:26:21
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 15 ms / 5,000 ms
コード長 1,021 bytes
コンパイル時間 468 ms
コンパイル使用メモリ 68,080 KB
実行使用メモリ 7,728 KB
最終ジャッジ日時 2023-08-18 11:16:17
合計ジャッジ時間 1,210 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

typedef pair<int, int> P;
typedef long long ll;

#define For(i, a, b) for(int i = (a); i < (b); i++)
#define Rep(i, n) For(i, 0, (n))

const double inf = 1e15;
const int mod = 1000000007;

double dp[1 << 15][20];
int x[20], y[20]; double w[20]; double all_w;
int dis[20][20];

int main(){
	int a, b; cin >> a >> b;
	int n; cin >> n;
	x[0] = a; y[0] = b;
	For(i, 1, n + 1){
		cin >> x[i] >> y[i] >> w[i];
		all_w += w[i];
	}
	n += 1;
	Rep(i, 1 << n) Rep(j, n) dp[i][j] = inf;
	dp[0][0] = 0;
	Rep(i, 1 << n) Rep(j, n) if(dp[i][j] < inf){
		double now_w = all_w;
		Rep(k, n) if(i & 1 << k) now_w -= w[k];
		Rep(k, n) if(!(i & 1 << k)){
			double dis = abs(x[j] - x[k]) + abs(y[j] - y[k]);
			double add_dis = dis * (now_w + 100.0) / 120;
			dp[i | 1 << k][k] = min(dp[i | 1 << k][k], dp[i][j] + add_dis + w[k]);
		}
	}
	printf("%.9f\n", dp[(1 << n) - 1][0]);
	return 0;
}
0