結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | udonman |
提出日時 | 2020-09-17 10:54:49 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 177 ms / 2,000 ms |
コード長 | 2,538 bytes |
コンパイル時間 | 1,167 ms |
コンパイル使用メモリ | 132,544 KB |
実行使用メモリ | 22,620 KB |
最終ジャッジ日時 | 2024-06-22 06:27:31 |
合計ジャッジ時間 | 5,738 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 86 ms
13,184 KB |
testcase_03 | AC | 122 ms
22,440 KB |
testcase_04 | AC | 118 ms
21,244 KB |
testcase_05 | AC | 97 ms
21,852 KB |
testcase_06 | AC | 96 ms
21,888 KB |
testcase_07 | AC | 34 ms
8,448 KB |
testcase_08 | AC | 124 ms
21,884 KB |
testcase_09 | AC | 13 ms
6,940 KB |
testcase_10 | AC | 58 ms
11,520 KB |
testcase_11 | AC | 39 ms
9,088 KB |
testcase_12 | AC | 19 ms
7,168 KB |
testcase_13 | AC | 85 ms
14,460 KB |
testcase_14 | AC | 99 ms
16,848 KB |
testcase_15 | AC | 119 ms
18,660 KB |
testcase_16 | AC | 55 ms
11,476 KB |
testcase_17 | AC | 127 ms
19,756 KB |
testcase_18 | AC | 39 ms
9,088 KB |
testcase_19 | AC | 122 ms
18,980 KB |
testcase_20 | AC | 32 ms
7,808 KB |
testcase_21 | AC | 45 ms
10,496 KB |
testcase_22 | AC | 111 ms
17,684 KB |
testcase_23 | AC | 3 ms
6,940 KB |
testcase_24 | AC | 3 ms
6,940 KB |
testcase_25 | AC | 17 ms
7,168 KB |
testcase_26 | AC | 67 ms
12,608 KB |
testcase_27 | AC | 65 ms
12,328 KB |
testcase_28 | AC | 109 ms
18,048 KB |
testcase_29 | AC | 12 ms
6,940 KB |
testcase_30 | AC | 114 ms
19,644 KB |
testcase_31 | AC | 81 ms
15,928 KB |
testcase_32 | AC | 53 ms
11,216 KB |
testcase_33 | AC | 116 ms
20,440 KB |
testcase_34 | AC | 41 ms
9,344 KB |
testcase_35 | AC | 124 ms
19,964 KB |
testcase_36 | AC | 2 ms
6,944 KB |
testcase_37 | AC | 4 ms
6,940 KB |
testcase_38 | AC | 3 ms
6,940 KB |
testcase_39 | AC | 3 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,940 KB |
testcase_41 | AC | 177 ms
22,620 KB |
testcase_42 | AC | 50 ms
9,216 KB |
testcase_43 | AC | 86 ms
13,696 KB |
testcase_44 | AC | 31 ms
7,168 KB |
testcase_45 | AC | 83 ms
13,196 KB |
testcase_46 | AC | 2 ms
6,940 KB |
testcase_47 | AC | 2 ms
6,940 KB |
ソースコード
#include <iostream>#include <string>#include <vector>#include <algorithm>#include <utility>#include <tuple>#include <cstdint>#include <cstdio>#include <map>#include <queue>#include <set>#include <stack>#include <deque>#include <unordered_map>#include <unordered_set>#include <bitset>#include <cctype>#include <numeric>#include <cmath>#include <iomanip> //cout << fixed << setprecision(15) << << endl;#include <cassert>#include <limits>//#include "atcoder/all"using namespace std;//using namespace atcoder;#define ll long long int#define pb push_back#define rep(i,n) for(int i=0;i<(n);i++)#define REP(i,n) for(int i=1;i<=(n);i++)//#define P pair<int,int>int mx8[] = {0,0,1,-1,-1,1,-1,1};int my8[] = {-1,1,0,0,-1,-1,1,1};int mx4[] = {1,-1,0,0};int my4[] = {0,0,-1,1};template<typename T>class Graph{public:struct Edge{int to;T cost;};struct edge{int from;int to;};vector<vector<Edge>> g;vector<edge> edges;int n;Graph(int n):n(n){g.resize(n);}void Add(int from, int to, T cost){g[from].push_back({to, cost});g[to].push_back({from, cost});}void Add_Edge(int from, int to){edges.push_back({from, to});}};template<typename T>vector<T> dijkstra(const Graph<T> &g, int start){using P = pair<T, int>;vector<T> dist(g.n, numeric_limits<T>::max());priority_queue<P, vector<P>, greater<P>> pq;dist[start] = 0;pq.push({dist[start], start});while (!pq.empty()){T expected = pq.top().first;int i = pq.top().second;pq.pop();if (dist[i] != expected){continue;}for (auto e : g.g[i]){int j = e.to;T c = e.cost;if (dist[j] > dist[i] + c){dist[j] = dist[i] + c;pq.push({dist[j], j});}}}return dist;}int main(){ios::sync_with_stdio(false);cin.tie(nullptr);int n, m, x, y;cin >> n >> m >> x >> y;--x; --y;vector<double> p(n),q(n);rep(i,n) cin >> p[i] >> q[i];Graph<double> G(n);rep(i,m){int P, Q; cin >> P >> Q;P--; Q--;double Co = sqrt(pow((p[P]-p[Q]),2) + pow((q[P]-q[Q]),2));G.Add(P,Q,Co);}vector<double> dist = dijkstra(G, x);cout << fixed << setprecision(17) << dist[y] << '\n';return 0;}