結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー 0w10w1
提出日時 2020-11-15 17:16:09
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 192 ms / 2,000 ms
コード長 882 bytes
コンパイル時間 2,042 ms
コンパイル使用メモリ 212,196 KB
実行使用メモリ 21,016 KB
最終ジャッジ日時 2023-09-30 07:01:50
合計ジャッジ時間 11,065 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 92 ms
10,516 KB
testcase_03 AC 145 ms
18,364 KB
testcase_04 AC 135 ms
17,516 KB
testcase_05 AC 95 ms
17,636 KB
testcase_06 AC 95 ms
17,648 KB
testcase_07 AC 30 ms
6,708 KB
testcase_08 AC 106 ms
16,948 KB
testcase_09 AC 11 ms
4,496 KB
testcase_10 AC 48 ms
9,076 KB
testcase_11 AC 32 ms
7,208 KB
testcase_12 AC 21 ms
4,532 KB
testcase_13 AC 99 ms
12,696 KB
testcase_14 AC 118 ms
15,424 KB
testcase_15 AC 151 ms
18,772 KB
testcase_16 AC 62 ms
8,872 KB
testcase_17 AC 161 ms
18,900 KB
testcase_18 AC 44 ms
7,044 KB
testcase_19 AC 139 ms
16,784 KB
testcase_20 AC 35 ms
7,000 KB
testcase_21 AC 48 ms
6,880 KB
testcase_22 AC 140 ms
16,780 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 2 ms
4,380 KB
testcase_25 AC 19 ms
4,424 KB
testcase_26 AC 70 ms
10,076 KB
testcase_27 AC 71 ms
10,244 KB
testcase_28 AC 134 ms
15,000 KB
testcase_29 AC 14 ms
4,432 KB
testcase_30 AC 153 ms
17,592 KB
testcase_31 AC 101 ms
14,396 KB
testcase_32 AC 68 ms
10,372 KB
testcase_33 AC 173 ms
21,016 KB
testcase_34 AC 48 ms
7,496 KB
testcase_35 AC 149 ms
17,872 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 3 ms
4,384 KB
testcase_38 AC 2 ms
4,380 KB
testcase_39 AC 3 ms
4,376 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 192 ms
16,960 KB
testcase_42 AC 50 ms
7,564 KB
testcase_43 AC 86 ms
10,336 KB
testcase_44 AC 32 ms
5,824 KB
testcase_45 AC 84 ms
10,424 KB
testcase_46 AC 2 ms
4,376 KB
testcase_47 AC 1 ms
4,380 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int N, M; { cin >> N >> M; }
  int Gx, Gy; { cin >> Gx >> Gy; --Gx, --Gy; }
  vector<int> X(N), Y(N); { for (int i = 0; i < N; ++i) cin >> X[i] >> Y[i]; }
  vector<vector<int>> G(N); {
    for (int i = 0; i < M; ++i) {
      int P, Q; { cin >> P >> Q; --P, --Q; }
      G[P].push_back(Q);
      G[Q].push_back(P);
    }
  }

  vector<double> dis(N, 1e20); {
    set<tuple<double, int>> bag;
    bag.emplace(dis[Gx] = 0, Gx);
    while (bag.size()) {
      double d;
      int u;
      tie(d, u) = *bag.begin();
      bag.erase(bag.begin());
      if (d != dis[u]) continue;
      for (int v : G[u]) {
        double nd = d + hypot(X[u] - X[v], Y[u] - Y[v]);
        if (nd < dis[v]) bag.emplace(dis[v] = nd, v);
      }
    }
  }

  cout << fixed << setprecision(9) << dis[Gy] << endl;
}
0