結果
問題 | No.134 走れ!サブロー君 |
ユーザー |
![]() |
提出日時 | 2017-12-01 01:26:21 |
言語 | C++11 (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 15 ms / 5,000 ms |
コード長 | 1,021 bytes |
コンパイル時間 | 601 ms |
コンパイル使用メモリ | 67,040 KB |
実行使用メモリ | 7,820 KB |
最終ジャッジ日時 | 2024-11-27 15:41:45 |
合計ジャッジ時間 | 1,179 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include <iostream>#include <algorithm>#include <cmath>#include <cstdlib>#include <vector>#include <queue>#include <utility>using namespace std;typedef pair<int, int> P;typedef long long ll;#define For(i, a, b) for(int i = (a); i < (b); i++)#define Rep(i, n) For(i, 0, (n))const double inf = 1e15;const int mod = 1000000007;double dp[1 << 15][20];int x[20], y[20]; double w[20]; double all_w;int dis[20][20];int main(){int a, b; cin >> a >> b;int n; cin >> n;x[0] = a; y[0] = b;For(i, 1, n + 1){cin >> x[i] >> y[i] >> w[i];all_w += w[i];}n += 1;Rep(i, 1 << n) Rep(j, n) dp[i][j] = inf;dp[0][0] = 0;Rep(i, 1 << n) Rep(j, n) if(dp[i][j] < inf){double now_w = all_w;Rep(k, n) if(i & 1 << k) now_w -= w[k];Rep(k, n) if(!(i & 1 << k)){double dis = abs(x[j] - x[k]) + abs(y[j] - y[k]);double add_dis = dis * (now_w + 100.0) / 120;dp[i | 1 << k][k] = min(dp[i | 1 << k][k], dp[i][j] + add_dis + w[k]);}}printf("%.9f\n", dp[(1 << n) - 1][0]);return 0;}