結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | leaf_1415 |
提出日時 | 2020-05-29 21:45:10 |
言語 | C++11 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 358 ms / 2,000 ms |
コード長 | 2,429 bytes |
コンパイル時間 | 1,001 ms |
コンパイル使用メモリ | 90,856 KB |
実行使用メモリ | 25,384 KB |
最終ジャッジ日時 | 2024-11-06 03:26:54 |
合計ジャッジ時間 | 8,824 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
10,828 KB |
testcase_01 | AC | 4 ms
10,768 KB |
testcase_02 | AC | 168 ms
17,420 KB |
testcase_03 | AC | 259 ms
25,384 KB |
testcase_04 | AC | 259 ms
25,128 KB |
testcase_05 | AC | 215 ms
25,260 KB |
testcase_06 | AC | 216 ms
25,148 KB |
testcase_07 | AC | 77 ms
14,584 KB |
testcase_08 | AC | 288 ms
22,260 KB |
testcase_09 | AC | 28 ms
12,372 KB |
testcase_10 | AC | 127 ms
17,008 KB |
testcase_11 | AC | 89 ms
14,672 KB |
testcase_12 | AC | 52 ms
12,360 KB |
testcase_13 | AC | 166 ms
20,524 KB |
testcase_14 | AC | 200 ms
20,816 KB |
testcase_15 | AC | 234 ms
21,828 KB |
testcase_16 | AC | 112 ms
18,576 KB |
testcase_17 | AC | 264 ms
23,380 KB |
testcase_18 | AC | 80 ms
14,020 KB |
testcase_19 | AC | 245 ms
21,712 KB |
testcase_20 | AC | 66 ms
13,288 KB |
testcase_21 | AC | 95 ms
16,728 KB |
testcase_22 | AC | 216 ms
22,068 KB |
testcase_23 | AC | 5 ms
10,712 KB |
testcase_24 | AC | 7 ms
11,896 KB |
testcase_25 | AC | 46 ms
12,228 KB |
testcase_26 | AC | 128 ms
17,716 KB |
testcase_27 | AC | 136 ms
17,064 KB |
testcase_28 | AC | 223 ms
22,492 KB |
testcase_29 | AC | 30 ms
11,336 KB |
testcase_30 | AC | 239 ms
23,056 KB |
testcase_31 | AC | 169 ms
20,096 KB |
testcase_32 | AC | 107 ms
16,580 KB |
testcase_33 | AC | 239 ms
23,660 KB |
testcase_34 | AC | 85 ms
15,956 KB |
testcase_35 | AC | 235 ms
23,156 KB |
testcase_36 | AC | 5 ms
9,156 KB |
testcase_37 | AC | 6 ms
11,652 KB |
testcase_38 | AC | 5 ms
9,288 KB |
testcase_39 | AC | 6 ms
10,848 KB |
testcase_40 | AC | 4 ms
9,544 KB |
testcase_41 | AC | 358 ms
22,908 KB |
testcase_42 | AC | 103 ms
15,060 KB |
testcase_43 | AC | 176 ms
17,764 KB |
testcase_44 | AC | 64 ms
13,852 KB |
testcase_45 | AC | 171 ms
17,832 KB |
testcase_46 | AC | 4 ms
10,548 KB |
testcase_47 | AC | 3 ms
9,288 KB |
ソースコード
#include <iostream> #include <cstdio> #include <cmath> #include <ctime> #include <cstdlib> #include <cassert> #include <vector> #include <list> #include <stack> #include <queue> #include <deque> #include <map> #include <set> #include <bitset> #include <string> #include <algorithm> #include <utility> #define llint long long #define inf 1e18 #define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++) #define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++) #define chmin(x, y) (x) = min((x), (y)) #define chmax(x, y) (x) = max((x), (y)) #define eps 1e-9 using namespace std; typedef pair<double, llint> P; struct edge{ llint to; double cost; edge(){} edge(llint a, double b){ to = a, cost = b; } }; struct vec2d{ double x, y; vec2d(){} vec2d(double x, double y){ this->x = x, this->y = y; } double add(double a, double b){ if(fabs(a+b) < eps * (fabs(a) + fabs(b))) return 0.0; return a+b; } vec2d operator+(vec2d ope){ return vec2d(add(x, ope.x), add(y, ope.y)); } vec2d operator-(vec2d ope){ return vec2d(add(x, -ope.x), add(y, -ope.y)); } vec2d operator*(double t){ return vec2d(x*t, y*t); } vec2d operator/(double t){ return vec2d(x/t, y/t); } double dot(vec2d ope){ return add(x*ope.x, y*ope.y); } double cross(vec2d ope){ return add(x*ope.y, -y*ope.x); } double norm(){ double d2 = dot(*this); if(d2 > 0) return sqrt(d2); return 0.0; } }; double distPP(vec2d p, vec2d q){ return (p-q).norm(); } llint n, m, s, t; vector<edge> G[200005]; vec2d p[200005]; double dist[200005]; void dijkstra(vector<edge> G[], llint S, double dist[]) { for(int i = 0; i <= n; i++) dist[i] = inf; dist[S] = 0; priority_queue< P, vector<P>, greater<P> > Q; Q.push( make_pair(0, S) ); llint v; double d; while(Q.size()){ d = Q.top().first; v = Q.top().second; Q.pop(); if(dist[v] < d) continue; for(int i = 0; i < G[v].size(); i++){ if(dist[G[v][i].to] > d + G[v][i].cost){ dist[G[v][i].to] = d + G[v][i].cost; Q.push( make_pair(dist[G[v][i].to], G[v][i].to) ); } } } } int main(void) { //ios::sync_with_stdio(0); //cin.tie(0); cin >> n >> m >> s >> t; for(int i = 1; i <= n; i++){ cin >> p[i].x >> p[i].y; } llint u, v; for(int i = 1; i <= m; i++){ cin >> u >> v; double w = distPP(p[u], p[v]); G[u].push_back(edge(v, w)); G[v].push_back(edge(u, w)); } dijkstra(G, s, dist); printf("%.11f\n", dist[t]); return 0; }