結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | 🍮かんプリン |
提出日時 | 2020-05-29 21:50:25 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 333 ms / 2,000 ms |
コード長 | 2,004 bytes |
コンパイル時間 | 1,748 ms |
コンパイル使用メモリ | 175,956 KB |
実行使用メモリ | 21,144 KB |
最終ジャッジ日時 | 2024-04-23 21:28:26 |
合計ジャッジ時間 | 8,593 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 146 ms
12,332 KB |
testcase_03 | AC | 216 ms
20,504 KB |
testcase_04 | AC | 212 ms
21,144 KB |
testcase_05 | AC | 177 ms
20,096 KB |
testcase_06 | AC | 184 ms
20,048 KB |
testcase_07 | AC | 59 ms
7,936 KB |
testcase_08 | AC | 229 ms
20,256 KB |
testcase_09 | AC | 21 ms
6,944 KB |
testcase_10 | AC | 100 ms
10,880 KB |
testcase_11 | AC | 67 ms
8,576 KB |
testcase_12 | AC | 46 ms
7,168 KB |
testcase_13 | AC | 141 ms
13,756 KB |
testcase_14 | AC | 170 ms
15,808 KB |
testcase_15 | AC | 201 ms
17,400 KB |
testcase_16 | AC | 98 ms
11,076 KB |
testcase_17 | AC | 215 ms
18,652 KB |
testcase_18 | AC | 71 ms
8,832 KB |
testcase_19 | AC | 194 ms
17,880 KB |
testcase_20 | AC | 53 ms
7,312 KB |
testcase_21 | AC | 87 ms
10,240 KB |
testcase_22 | AC | 191 ms
16,704 KB |
testcase_23 | AC | 3 ms
6,940 KB |
testcase_24 | AC | 4 ms
6,944 KB |
testcase_25 | AC | 41 ms
6,944 KB |
testcase_26 | AC | 106 ms
11,812 KB |
testcase_27 | AC | 107 ms
11,756 KB |
testcase_28 | AC | 188 ms
17,152 KB |
testcase_29 | AC | 24 ms
6,944 KB |
testcase_30 | AC | 197 ms
18,556 KB |
testcase_31 | AC | 140 ms
15,048 KB |
testcase_32 | AC | 86 ms
10,604 KB |
testcase_33 | AC | 192 ms
19,348 KB |
testcase_34 | AC | 70 ms
8,960 KB |
testcase_35 | AC | 196 ms
18,884 KB |
testcase_36 | AC | 3 ms
6,940 KB |
testcase_37 | AC | 3 ms
6,940 KB |
testcase_38 | AC | 3 ms
6,940 KB |
testcase_39 | AC | 4 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,940 KB |
testcase_41 | AC | 333 ms
21,016 KB |
testcase_42 | AC | 84 ms
8,960 KB |
testcase_43 | AC | 148 ms
12,800 KB |
testcase_44 | AC | 50 ms
6,940 KB |
testcase_45 | AC | 143 ms
12,544 KB |
testcase_46 | AC | 2 ms
6,940 KB |
testcase_47 | AC | 2 ms
6,940 KB |
ソースコード
/** * @FileName b.cpp * @Author kanpurin * @Created 2020.05.29 21:50:20 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; // dijkstra O(ElogV) // verify : https://onlinejudge.u-aizu.ac.jp/problems/GRL_1_A // ※拡張ダイクストラ template<typename T> struct Dijkstra { private: int V; struct edge { int to; T cost; }; vector<vector<edge>> G; public: const T inf = numeric_limits<T>::max(); // s から i の最小コスト // 経路がない場合は inf vector<T> d; // (頂点) ※ Dijkstra(int V) : V(V) { G.resize(V); } // 辺の追加 // 有向の場合 directed = true void add_edge(int from, int to, T weight, bool directed = false) { G[from].push_back({to,weight}); if (!directed) G[to].push_back({from,weight}); } void build(int s) { d.assign(V, inf); // ※ typedef tuple<T, int> P; //(距離,頂点) ※ priority_queue<P, vector<P>, greater<P>> pq; d[s] = 0; // ※ pq.push(P(d[s], s)); // ※ while (!pq.empty()) { P p = pq.top(); pq.pop(); int v = get<1>(p); // ※ if (d[v] < get<0>(p)) continue; // ※ for (const edge &e : G[v]) { // ※ if (d[e.to] > d[v] + e.cost) { d[e.to] = d[v] + e.cost; pq.push(P(d[e.to], e.to)); } } } } }; int main() { int n,m;cin >> n >> m; int s,t;cin >> s >> t; s--;t--; Dijkstra<double> g(n); vector<pair<int,int>> p(n); for (int i = 0; i < n; i++) { cin >> p[i].first >> p[i].second; } for (int i = 0; i < m; i++) { int u,v;cin >> u >> v; u--;v--; g.add_edge(u,v,sqrt((p[u].first-p[v].first)*(p[u].first-p[v].first)+(p[u].second-p[v].second)*(p[u].second-p[v].second))); } g.build(s); printf("%.10f\n",g.d[t]); return 0; }