結果
問題 | No.134 走れ!サブロー君 |
ユーザー |
![]() |
提出日時 | 2020-04-09 09:48:50 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 7 ms / 5,000 ms |
コード長 | 1,814 bytes |
コンパイル時間 | 2,404 ms |
コンパイル使用メモリ | 180,832 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-21 16:00:23 |
合計ジャッジ時間 | 2,621 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 15 |
ソースコード
#pragma GCC optimize("Ofast")#include <bits/stdc++.h>using namespace std;#define rep(i, n) for(int i = 0; i < (n); ++i)#define all(x) (x).begin(),(x).end()#define ln '\n'constexpr long long MOD = 1000000007LL;//constexpr long long MOD = 998244353LL;typedef long long ll;typedef unsigned long long ull;typedef pair<int, int> pii;typedef pair<long long, long long> pll;template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////double dp[10000][15];double dist(double x1, double y1, double x2, double y2) {return abs(x1-x2)+abs(y1-y2);}int main() {ios::sync_with_stdio(false); cin.tie(nullptr);double X0,Y0; cin >> X0 >> Y0;int N; cin >> N;vector<double> X(N),Y(N),W(N);rep(i,N) cin >> X[i] >> Y[i] >> W[i];rep(mask,1<<N) rep(j,N) dp[mask][j] = 1e9;rep(mask,1<<N) {double S = 0;rep(i,N) {if (!(mask&(1<<i))) S += W[i];}if (!mask) {rep(i,N) {chmin(dp[mask+(1<<i)][i],dist(X0,Y0,X[i],Y[i])*(S+100)/120.0+W[i]);}} else {rep(i,N) {if (mask&(1<<i)) continue;rep(j,N) {if (mask&(1<<j)) {chmin(dp[mask+(1<<i)][i],dp[mask][j]+dist(X[i],Y[i],X[j],Y[j])*(S+100)/120.0+W[i]);}}}}}double ans = 1e9;rep(i,N) chmin(ans, dp[(1<<N)-1][i] + 100.0*dist(X0,Y0,X[i],Y[i])/120);cout << fixed << setprecision(10) << ans << ln;}