結果
| 問題 | No.134 走れ!サブロー君 | 
| コンテスト | |
| ユーザー |  otsnsk | 
| 提出日時 | 2015-01-25 23:26:42 | 
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,735 bytes | 
| コンパイル時間 | 650 ms | 
| コンパイル使用メモリ | 73,480 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-06-23 02:51:13 | 
| 合計ジャッジ時間 | 1,398 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| other | AC * 11 WA * 4 | 
ソースコード
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#define FORR(i,b,e) for(int i=(b);i<(int)(e);++i)
#define FOR(i,e) FORR(i,0,e)
#define dump(var) cerr << #var ": " << var << "\n"
#define dumpc(con) for(auto& e: con) cerr << e << " "; cerr<<"\n"
typedef long long ll;
typedef unsigned long long ull;
const double EPS = 1e-6;
const int d4[] = {0, -1, 0, 1, 0};
using namespace std;
struct Customer {
    int x, y;
    double w;
};
struct Node {
    int cid;
    double w, t;
};
double dist(Customer &a, Customer &b) {
    return abs(a.x-b.x) + abs(a.y-b.y);
}
const double TINF = 999999;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x0, y0, N;
    cin >> x0 >> y0 >> N;
    vector<Customer> c(N+1);
    double w0 = 0;
    FOR(i, N) {
        cin >> c[i].x >> c[i].y >> c[i].w;
        w0 += c[i].w;
    }
    c[N].x = x0; c[N].y = y0; c[N].w = 0;
    vector<Node> v(1<<N);
    int last_state = (1<<N)-1;
    FOR(i, 1<<N) v[i].t = TINF;
    v[0].w = w0; v[0].t = 0; v[0].cid = N;
    FORR(i, 1, 1<<N) {
        Node &cur = v[i];
        int b = 1;
        for (int j = 0; b <= i; b <<= 1, ++j) {
            if (i & b) {
                Node &pre = v[i^b];
                Customer &d = c[j], &s = c[pre.cid];
                double t = pre.t
                         + dist(s,d)*(pre.w+100.0)/120
                         + d.w
                         + (i==last_state? dist(d, c[N])*100/120: 0);
                if (t < cur.t) {
                    cur.t = t;
                    cur.cid = j;
                    cur.w = pre.w - d.w;
                }
            }
        }
    }
    cout << fixed << setprecision(8);
    cout << v[last_state].t << endl;
    return 0;
}
            
            
            
        