結果
| 問題 | No.134 走れ!サブロー君 |
| コンテスト | |
| ユーザー |
Kutimoti_T
|
| 提出日時 | 2018-03-06 14:50:57 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 2,096 bytes |
| 記録 | |
| コンパイル時間 | 560 ms |
| コンパイル使用メモリ | 82,768 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-09-18 22:48:10 |
| 合計ジャッジ時間 | 1,168 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 2 WA * 13 |
ソースコード
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
typedef long long i64;
typedef long double ld;
typedef pair<i64, i64> P;
#define rep(i, s, e) for (int i = (s); i <= (e); i++)
ld sx, sy;
int n;
ld x[13], y[13], w[13];
ld dp[(1 << 13)];
ld dist(ld x1, ld y1, ld x2, ld y2)
{
return abs(x1 - x2) + abs(y1 - y2);
}
int main()
{
cin >> sx >> sy;
cin >> n;
rep(i, 0, n - 1) cin >> x[i] >> y[i] >> w[i];
fill(dp, dp + (1 << 13), 1e9);
ld w_sum = 0;
rep(i, 0, n - 1) w_sum += w[i];
rep(i, 1, (1 << n) - 1)
{
if (__builtin_popcount(i) == 1)
{
rep(j, 0, n - 1)
{
if (i & (1 << j))
{
dp[i] = dist(x[j], y[j], sx, sy) * (w_sum + 100) / 120 + w[j];
break;
}
}
}
else
{
rep(j, 0, n - 1)
{
if (i & (1 << j))
{
ld weight = 0;
int sub = i & ~(1 << j);
rep(k, 0, n - 1)
{
if (!(sub & (1 << k)))
{
weight += w[k];
}
}
rep(k, 0, n - 1)
{
if ((sub & (1 << k)))
{
ld d = dist(x[j], y[j], x[k], y[k]);
ld last = 0;
if (i == (1 << n) - 1)
{
last += dist(x[j], y[j], sx, sy) * 100 / 120;
}
dp[i] = min(dp[i], dp[sub] + d * (weight + 100) / 120 + w[j] + last);
}
}
}
}
}
}
cout << fixed << setprecision(10);
cout << dp[(1 << n) - 1] << endl;
}
Kutimoti_T