結果

問題 No.134 走れ!サブロー君
ユーザー evimaevima
提出日時 2015-01-22 23:37:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 10 ms / 5,000 ms
コード長 1,252 bytes
コンパイル時間 1,166 ms
コンパイル使用メモリ 145,736 KB
実行使用メモリ 5,544 KB
最終ジャッジ日時 2023-08-04 19:50:27
合計ジャッジ時間 1,812 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ(β)

テストケース

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

ソースコード

diff #

// Enjoy your stay.

#include <bits/stdc++.h>

#define EPS 1e-9
#define INF 1070000000LL
#define MOD 1000000007LL
#define all(x) (x).begin(),(x).end()
#define fir first
#define foreach(it,X) for(auto it=(X).begin();it!=(X).end();it++)
#define ite iterator
#define mp make_pair
#define mt make_tuple
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define pb push_back
#define sec second
#define sz(x) ((int)(x).size())

using namespace std;

typedef istringstream iss;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef stringstream sst;
typedef vector<ll> vi;

int n;
int x[14],y[14];
double w[14];
double dp[14][1<<14];

int d(int i,int j){
	return abs(x[i]-x[j])+abs(y[i]-y[j]);
}

double f(int cur,int mask){
	double& res = dp[cur][mask];
	if(res != -INF) return res;
	res = INF;
	double W = 0;
	rep(i,n)if(mask>>i&1) W += w[i];
	double T = (W + 100) / 120.;
	if(mask == 0){
		res = T * d(cur,0);
	}else{
		rep2(i,1,n)if(mask>>i&1){
			res = min(res, w[i]+T*d(cur,i) + f(i,mask^1<<i));
		}
	}
	return res;
}

int main(){
	cin.tie(0);
	ios_base::sync_with_stdio(0);
	
	cin>>x[0]>>y[0]>>n;
	n++;
	rep2(i,1,n){
		cin>>x[i]>>y[i]>>w[i];
	}
	rep(i,n)rep(j,1<<n)dp[i][j]=-INF;
	cout<<setprecision(16)<<f(0,(1<<n) - 2)<<endl;
}
0