結果

問題 No.134 走れ!サブロー君
ユーザー ttkkggwwttkkggww
提出日時 2022-05-11 03:23:43
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 1,051 bytes
コンパイル時間 4,160 ms
コンパイル使用メモリ 262,688 KB
実行使用メモリ 4,556 KB
最終ジャッジ日時 2023-09-25 12:43:02
合計ジャッジ時間 5,114 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
4,420 KB
testcase_01 AC 2 ms
4,424 KB
testcase_02 AC 2 ms
4,504 KB
testcase_03 AC 2 ms
4,492 KB
testcase_04 AC 2 ms
4,504 KB
testcase_05 AC 3 ms
4,452 KB
testcase_06 AC 3 ms
4,416 KB
testcase_07 AC 5 ms
4,424 KB
testcase_08 AC 9 ms
4,492 KB
testcase_09 AC 9 ms
4,556 KB
testcase_10 AC 2 ms
4,508 KB
testcase_11 AC 2 ms
4,420 KB
testcase_12 AC 2 ms
4,504 KB
testcase_13 AC 2 ms
4,452 KB
testcase_14 AC 2 ms
4,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include<atcoder/all>
using namespace atcoder;
using ll = long long;
double sx,sy;
int n;
vector<double> x,y,w;

double dp[1<<13][13];

void solve(){
	for(int i = 0;i< (1<<13);i++){
		for(int j = 0;j<13;j++)dp[i][j] = 1e18;
	}
	dp[0][0] = 0;
	for(int bit = 0;bit<(1<<n);bit++){
		for(int j = 0;j<n;j++){
		double t = 100.0/120.0;
		for(int i = 0;i<n;i++){
			if((bit>>i&1)==0){
				t += w[i]/120.0;
			}
		}
		for(int i = 0;i<n;i++){
			if((bit>>i&1)==0){
				double dist = abs(x[i]-x[j])+abs(y[i]-y[j]);
				if(bit==0&&j==0)dist = abs(x[i]-sx) + abs(y[i]-sy);
				dp[bit + (1<<i)][i] = min(dp[bit+(1<<i)][i],dp[bit][j]+t*dist+w[i]);
			}
		}
		}
	}
	double ans = 1e18;
	for(int i = 0;i<n;i++){
		ans = min(ans,abs(x[i]-sx)*100.0/120.0+abs(y[i]-sy)*100.0/120.0+dp[(1<<n)-1][i]);
	}
	printf("%.10lf\n",ans);
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cin >> sx >> sy;
	cin >> n;
	x = y = w = vector<double>(n);
	for(int i = 0;i<n;i++){
		cin >> x[i] >> y[i] >> w[i];
	}
	solve();
}
0