結果

問題 No.134 走れ!サブロー君
ユーザー nxterunxteru
提出日時 2018-06-30 13:36:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 830 bytes
コンパイル時間 626 ms
コンパイル使用メモリ 77,880 KB
実行使用メモリ 5,532 KB
最終ジャッジ日時 2023-09-13 16:16:57
合計ジャッジ時間 1,434 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <cstdio>
#include <cstring>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define F first
#define S second
double x[15],y[15],w[15],dp[15][1<<15],s;
int n;
int main(void){
    cin>>x[0]>>y[0]>>n;
    n++;
    for(int i=1;i<n;i++)cin>>x[i]>>y[i]>>w[i];
    for(int i=0;i<n;i++)for(int j=0;j<1<<n;j++)dp[i][j]=500000;
    dp[0][0]=0;
    for(int k=0;k<1<<n;k++){
        s=0;
        for(int i=1;i<n;i++)if(!(k>>i&1))s+=w[i];
        for(int p=0;p<n;p++){
        for(int i=0;i<n;i++){
            if(!(k>>i&1)){
                dp[i][k|1<<i]=min(dp[i][k|1<<i],dp[p][k]+(abs(x[p]-x[i])+abs(y[p]-y[i]))*(s+100)/120+w[i]);
            }
        }
        }
    }
    cout<<dp[0][(1<<n)-1]<<endl;
}
0