結果

問題 No.134 走れ!サブロー君
ユーザー h_nosonh_noson
提出日時 2016-04-23 14:32:12
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 1,297 bytes
コンパイル時間 579 ms
コンパイル使用メモリ 68,820 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-04-15 04:18:33
合計ジャッジ時間 993 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,812 KB
testcase_01 AC 2 ms
6,944 KB
testcase_02 AC 2 ms
6,940 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 7 ms
6,940 KB
testcase_10 AC 2 ms
6,940 KB
testcase_11 AC 2 ms
6,940 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 2 ms
6,944 KB
testcase_14 AC 2 ms
6,944 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
using namespace std;

#define RREP(i,s,e) for (i = s; i >= e; i--)
#define rrep(i,n) RREP(i,n,0)
#define REP(i,s,e) for (i = s; i < e; i++)
#define rep(i,n) REP(i,0,n)
#define INF 100000000

typedef long long ll;

int main() {
    int i, j, k, x0, y0, n, sum;
    double ans;
    double dp[1<<13][13];
    double item[13][3];
    cin >> x0 >> y0 >> n;
    sum = 0;
    rep (i,n) {
        rep (j,3) cin >> item[i][j];
        sum += item[i][2];
    }
    rep (i,n) dp[1<<i][i] = (sum + 100) * (abs(item[i][0]-x0) + abs(item[i][1]-y0)) / 120 + item[i][2];
    REP (i,1,1<<n) {
        rep (j,n) {
            if (!(i & 1<<j)) {
                dp[i|1<<j][j] = INF;
                sum = 0;
                rep (k,n) if (!(i & 1<<k)) sum += item[k][2];
                rep (k,n) if (i & 1<<k) {
                    double cost = (sum+100) * (abs(item[k][0] - item[j][0]) + abs(item[k][1] - item[j][1])) / 120 + item[j][2];
                    dp[i|1<<j][j] = min(dp[i|1<<j][j],dp[i][k]+cost);
                }
            }
        }
    }
    ans = INF;
    rep (i,n) ans = min(ans,dp[(1<<n)-1][i]+100.0*(abs(item[i][0]-x0)+abs(item[i][1]-y0))/120);
    cout << fixed << setprecision(8) << ans << endl;
    return 0;
}
0