結果

問題 No.134 走れ!サブロー君
ユーザー fiordfiord
提出日時 2015-08-18 23:23:02
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 867 bytes
コンパイル時間 1,227 ms
コンパイル使用メモリ 151,744 KB
実行使用メモリ 5,592 KB
最終ジャッジ日時 2023-09-25 12:56:38
合計ジャッジ時間 2,109 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 11 ms
5,592 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,380 KB
testcase_14 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
double dp[1<<14][14];
double weight[1<<14];
int main(){
	int sx,sy;	cin>>sx>>sy;
	int n;	cin>>n;
	vector<int> x(n),y(n);
	vector<double> w(n);
	for(int i=0;i<n;i++)	cin>>x[i]>>y[i]>>w[i];
	x.insert(x.begin(),sx);	y.insert(y.begin(),sy);	w.insert(w.begin(),0.0);
	n++;
	int sw=0;
	for(int i=0;i<n;i++)	sw+=w[i];
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if((i>>j)%2)	weight[i]+=w[j];
		}
		weight[i]=sw-weight[i];
	}
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++)	dp[i][j]=(1<<30);
	}
	dp[0][0]=0;
	for(int i=0;i<(1<<n);i++){
		for(int j=0;j<n;j++){
			if(dp[i][j]==(1<<30))	continue;
			for(int k=0;k<n;k++){
				int next=(i|(1<<k));
				dp[next][k]=min(dp[next][k],dp[i][j]+(double)(abs(x[j]-x[k])+abs(y[j]-y[k]))*(weight[i]+100)/120+w[k]);
			}
		}
	}
	printf("%.15lf\n",dp[(1<<n)-1][0]);
	return 0;
}
0