結果

問題 No.134 走れ!サブロー君
ユーザー ytftytft
提出日時 2021-03-15 11:09:23
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,323 bytes
コンパイル時間 1,886 ms
コンパイル使用メモリ 170,280 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-24 15:25:23
合計ジャッジ時間 2,521 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;


int main(){
    double inf=DBL_MAX;
    int N,x,y;
    double weight=0;
    double all;
    cin>>x>>y>>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[i]-=x;
        Y[i]-=y;
        weight+=W[i];
    }
    all=weight;
    double temp;
    vector<vector<double>> dp(N,vector<double>(1<<N,-1));
    for(int i=0;i<N;i++){
        dp[i][1<<i]=(weight+100)/120*(abs(X[i])+abs(Y[i]));
    }
    for(int j=0;j<(1<<N);j++){
        for(int i=0;i<N;i++){
            weight=0;
            for(int k=0;k<N;k++){
                if((j>>k)%2==0){
                    weight+=W[k];
                }
            }
            if((j>>i)%2==0){
                dp[i][j]=0;
            }else if(dp[i][j]==-1){
                temp=inf;
                cout<<i<<" "<<j<<endl;
                for(int k=0;k<N;k++){
                    if(k!=i && (j>>k)%2==1){
                        temp=min(temp,dp[k][j-(1<<i)]+((weight+W[i]+100)/120)*(abs(X[i]-X[k])+abs(Y[i]-Y[k])));
                    }
                }
                dp[i][j]=temp;
            }
        }
    }
    temp=inf;
    for(int i=0;i<N;i++){
        temp=min(temp,dp[i][(1<<N)-1]+100*(abs(X[i])+abs(Y[i]))/120.0);
    }
    cout<<temp+all<<endl;
}
0