結果

問題 No.134 走れ!サブロー君
ユーザー furafura
提出日時 2020-06-08 01:51:59
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 11 ms / 5,000 ms
コード長 774 bytes
コンパイル時間 1,998 ms
コンパイル使用メモリ 202,088 KB
実行使用メモリ 5,440 KB
最終ジャッジ日時 2023-08-25 14:39:37
合計ジャッジ時間 2,932 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,380 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 3 ms
4,388 KB
testcase_06 AC 3 ms
4,380 KB
testcase_07 AC 6 ms
4,380 KB
testcase_08 AC 10 ms
5,276 KB
testcase_09 AC 11 ms
5,440 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>

#define rep(i,n) for(int i=0;i<(n);i++)

using namespace std;

const double INF=1e77;

int main(){
	double x0,y0;
	int n; scanf("%lf%lf%d",&x0,&y0,&n);
	vector<double> x(n+1),y(n+1),w(n+1);
	rep(i,n) scanf("%lf%lf%lf",&x[i],&y[i],&w[i]);
	x[n]=x0;
	y[n]=y0;
	n++;

	double d[14][14];
	rep(i,n) rep(j,n) d[i][j]=abs(x[i]-x[j])+abs(y[i]-y[j]);

	double dp[1<<14][14];
	rep(S,1<<n) rep(i,n) dp[S][i]=INF;
	dp[1<<(n-1)][n-1]=0;
	rep(S,1<<n){
		double wsum=0;
		rep(i,n) if((S>>i&1)==0) wsum+=w[i];
		rep(i,n) if(S>>i&1) {
			rep(j,n) if((S>>j&1)==0) {
				dp[S|1<<j][j]=min(dp[S|1<<j][j],dp[S][i]+d[i][j]*(wsum+100)/120+w[j]);
			}
		}
	}

	double ans=INF;
	rep(i,n) ans=min(ans,dp[(1<<n)-1][i]+d[i][n-1]*100/120);
	printf("%.9f\n",ans);

	return 0;
}
0