結果
| 問題 |
No.134 走れ!サブロー君
|
| コンテスト | |
| ユーザー |
taka99_xyz
|
| 提出日時 | 2022-12-22 21:21:47 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 14 ms / 5,000 ms |
| コード長 | 1,934 bytes |
| コンパイル時間 | 1,921 ms |
| コンパイル使用メモリ | 199,692 KB |
| 最終ジャッジ日時 | 2025-02-09 18:25:52 |
|
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 15 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define PRINT(a) cout << (a) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define Fi first
#define Se second
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';
using ll = long long int;
using P = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
int main(){
double x0, y0;
cin >> x0 >> y0;
int n;
cin >> n;
n++;
int S = 1<<n;
vector<double> x(n), y(n), w(n);
x[0]=x0;
y[0]=y0;
REP(i,n-1)cin >> x[i+1] >> y[i+1] >> w[i+1];
const double INF=1e18;
vector dp(S, vector<double>(n, INF));
dp[0][0]=0;
double tot = 0;
REP(i,n)tot += w[i];
vector<double> t(S,tot);
REP(s, S){
REP(j,n){
if((s >> j) & 1)t[s] -= w[j];
}
}
vector dist(n, vector<double>(n));
REP(i,n)REP(j,n){
dist[i][j] = abs(x[i]-x[j]) + abs((y[i]-y[j]));
}
REP(s, S){
// u -> v
REP(u, n){
if(dp[s][u]==INF)continue;
REP(v, n){
if( ~s & (1<<v)){
chmin(dp[s | (1<<v)][v], dp[s][u] + dist[u][v] * ((t[s] + 100)/120) + w[v]);
}
}
}
}
// REP(s, S){
// // u -> v
// REP(u, n){
// if(dp[s][u]==INF)continue;
// printf("%d %d %.10f\n", s, u, dp[s][u]);
// }
// }
printf("%.10f\n", dp[S-1][0]);
}
taka99_xyz