結果
問題 | No.134 走れ!サブロー君 |
ユーザー |
![]() |
提出日時 | 2023-10-14 08:59:31 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 1,868 bytes |
コンパイル時間 | 1,890 ms |
コンパイル使用メモリ | 198,848 KB |
最終ジャッジ日時 | 2025-02-17 07:45:18 |
ジャッジサーバーID (参考情報) |
judge4 / judge6 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#include <bits/stdc++.h>using namespace std;#define rep(i,n) for(int i=0; i<(n); i++)#define rep1(i,n) for(int i=1; i<=(n); i++)#define sz(x) int(x.size())#define all(x) (x).begin(),(x).end()#define Q2 1000000007#define Q 998244353#define lINF LONG_LONG_MAX //ll#define iINF 1e9 //int#define yes "Yes"#define no "No"#define kotae cout<<ans<<endl;#define dame { puts("0"); return 0;}#define yn {puts("Yes");}else{puts("No");}using ll=long long;using ull=unsigned long long;using P=pair<int,int>;using pqg=priority_queue<int,vector<int>,greater<int>>;using vi=vector<int>;using vi2=vector<vector<int>>;using vi3=vector<vector<vector<int>>>;using vl=vector<ll>;using vl2=vector<vector<ll>>;using vl3=vector<vector<vector<ll>>>;using vs=vector<string>;using vp=vector<P>;using vp2=vector<vector<P>>;void chmax(int &x, int y){ x=max(x,y); return; }void chmin(double &x, double y){ x=min(x,y); return; }void chmaxl(ll &x, ll y){ x=max(x,y); return; }void chminl(ll &x, ll y){ x=min(x,y); return; }struct A{int x,y;double w;};int main() {int x,y;cin >> x >> y;int n;cin >> n;vector<A>a(n);rep(i,n) cin >> a[i].x >> a[i].y >> a[i].w;int s=1<<n;vector<vector<double>> dp(s,vector<double>(n,iINF));double tot=0;double l=100,r=120;rep(i,n) tot+=a[i].w;rep(i,n) dp[1<<i][i]=(abs(a[i].x-x)+abs(a[i].y-y))*(tot+100)/120+a[i].w;rep(i,s){rep(j,n){ //goto jif((i>>j)&1) continue;double nw=tot;rep(k,n) if((i>>k)&1) nw-=a[k].w;double t=(nw+100)/120;rep(k,n){ //from kif(!(i>>k)&1) continue;double nt=(abs(a[j].x-a[k].x)+abs(a[j].y-a[k].y))*t;chmin (dp[i|(1<<j)][j], dp[i][k]+nt+a[j].w);}}}double ans=iINF;rep(i,n) chmin(ans,dp[s-1][i]+(abs(a[i].x-x)+abs(a[i].y-y))*l/r);printf("%.10f\n",ans);return 0;}