結果
問題 | No.2955 Pizza Delivery Plan |
ユーザー |
![]() |
提出日時 | 2024-11-08 21:59:55 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 311 ms / 2,000 ms |
コード長 | 1,583 bytes |
コンパイル時間 | 3,238 ms |
コンパイル使用メモリ | 276,732 KB |
実行使用メモリ | 61,440 KB |
最終ジャッジ日時 | 2024-11-08 22:00:05 |
合計ジャッジ時間 | 9,323 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 28 |
ソースコード
#include<bits/stdc++.h>namespace {#pragma GCC diagnostic ignored "-Wunused-function"#include<atcoder/all>#pragma GCC diagnostic warning "-Wunused-function"using namespace std;using namespace atcoder;#define rep(i,n) for(int i = 0; i < (int)(n); i++)#define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--)#define all(x) begin(x), end(x)#define rall(x) rbegin(x), rend(x)template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; }using ll = long long;using P = pair<int,int>;using VI = vector<int>;using VVI = vector<VI>;using VL = vector<ll>;using VVL = vector<VL>;double dp[1 << 15][15][15];double dist[15][15];} int main() {ios::sync_with_stdio(false);cin.tie(0);int n, k;cin >> n >> k;vector<P> xy(n);for (auto& [x, y] : xy) cin >> x >> y;xy.insert(xy.begin(), 1, pair(0, 0));rep(i, n + 1) rep(j, n + 1) {int dx = xy[i].first - xy[j].first;int dy = xy[i].second - xy[j].second;dist[i][j] = sqrt(ll(dx) * dx + ll(dy) * dy);}constexpr double inf = 1e20;rep(s, 1 << 15) rep(v, 15) rep(kv, 15) dp[s][v][kv] = inf;dp[1][0][k] = 0;rep(s, 1 << (n + 1)) {rep(u, n + 1) rep(ku, k + 1) {chmin(dp[s][0][k], dp[s][u][ku] + dist[u][0]);}rep(u, n + 1) rep(ku, k + 1) if (ku) rep(v, n + 1) {chmin(dp[s | 1 << v][v][ku - 1], dp[s][u][ku] + dist[u][v]);}}cout << fixed << setprecision(12) << dp[(1 << (n + 1)) - 1][0][k] << '\n';}