結果
問題 | No.1065 電柱 / Pole (Easy) |
ユーザー | tanimani364 |
提出日時 | 2020-05-29 21:42:31 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 222 ms / 2,000 ms |
コード長 | 2,341 bytes |
コンパイル時間 | 2,685 ms |
コンパイル使用メモリ | 208,204 KB |
実行使用メモリ | 25,660 KB |
最終ジャッジ日時 | 2024-04-23 20:54:36 |
合計ジャッジ時間 | 7,497 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,812 KB |
testcase_01 | AC | 1 ms
6,944 KB |
testcase_02 | AC | 106 ms
14,720 KB |
testcase_03 | AC | 163 ms
24,428 KB |
testcase_04 | AC | 157 ms
24,964 KB |
testcase_05 | AC | 141 ms
25,596 KB |
testcase_06 | AC | 130 ms
25,084 KB |
testcase_07 | AC | 44 ms
9,216 KB |
testcase_08 | AC | 156 ms
25,056 KB |
testcase_09 | AC | 16 ms
6,944 KB |
testcase_10 | AC | 72 ms
13,056 KB |
testcase_11 | AC | 49 ms
9,984 KB |
testcase_12 | AC | 34 ms
8,704 KB |
testcase_13 | AC | 112 ms
17,040 KB |
testcase_14 | AC | 128 ms
19,436 KB |
testcase_15 | AC | 145 ms
21,320 KB |
testcase_16 | AC | 73 ms
13,416 KB |
testcase_17 | AC | 161 ms
22,868 KB |
testcase_18 | AC | 53 ms
10,624 KB |
testcase_19 | AC | 152 ms
21,704 KB |
testcase_20 | AC | 41 ms
8,576 KB |
testcase_21 | AC | 64 ms
12,672 KB |
testcase_22 | AC | 139 ms
20,236 KB |
testcase_23 | AC | 3 ms
6,944 KB |
testcase_24 | AC | 4 ms
6,940 KB |
testcase_25 | AC | 30 ms
8,448 KB |
testcase_26 | AC | 82 ms
14,136 KB |
testcase_27 | AC | 85 ms
14,252 KB |
testcase_28 | AC | 140 ms
21,172 KB |
testcase_29 | AC | 20 ms
6,940 KB |
testcase_30 | AC | 147 ms
22,424 KB |
testcase_31 | AC | 100 ms
17,764 KB |
testcase_32 | AC | 68 ms
12,608 KB |
testcase_33 | AC | 149 ms
23,608 KB |
testcase_34 | AC | 59 ms
10,752 KB |
testcase_35 | AC | 153 ms
22,900 KB |
testcase_36 | AC | 3 ms
6,940 KB |
testcase_37 | AC | 3 ms
6,940 KB |
testcase_38 | AC | 3 ms
6,944 KB |
testcase_39 | AC | 3 ms
6,940 KB |
testcase_40 | AC | 2 ms
6,940 KB |
testcase_41 | AC | 222 ms
25,660 KB |
testcase_42 | AC | 58 ms
10,496 KB |
testcase_43 | AC | 107 ms
15,204 KB |
testcase_44 | AC | 39 ms
7,808 KB |
testcase_45 | AC | 109 ms
14,976 KB |
testcase_46 | AC | 1 ms
6,940 KB |
testcase_47 | AC | 2 ms
6,940 KB |
ソースコード
#include <bits/stdc++.h> #define rep(i, a) for (int i = (int)0; i < (int)a; ++i) #define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i) #define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i) #define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i) #define pb push_back #define eb emplace_back #define all(x) x.begin(), x.end() #define rall(x) x.rbegin(), x.rend() using ll = long long; constexpr ll mod = 1e9 + 7; constexpr ll INF = 1LL << 60; template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } ll gcd(ll n, ll m) { ll tmp; while (m != 0) { tmp = n % m; n = m; m = tmp; } return n; } ll lcm(ll n, ll m) { return abs(n) / gcd(n, m) * abs(m); //gl=xy } using namespace std; template<typename T> struct edge{ int to; T cost; edge(int to,T cost):to(to),cost(cost){} }; template<typename T> vector<T> dijkstra(vector<vector<edge<T>>> &g,int s){//sは始点 const auto INFTY=numeric_limits<T>::max();//2回以上使うときはオーバーフローに気をつける(INFTYのときはif文で弾くなど) vector<T>dist(g.size(),INFTY); using P=pair<T,int>;//firstは最短距離,secondは頂点の番号 priority_queue<P,vector<P>,greater<P>>pq; dist[s]=0; pq.emplace(dist[s],s); while(!pq.empty()){ auto x=pq.top();pq.pop(); int v=x.second; if(dist[v]<x.first)continue;//最短距離でなければ飛ばす for(auto e:g[v]){ if(dist[e.to]>dist[v]+e.cost){ dist[e.to]=dist[v]+e.cost; pq.emplace(dist[e.to],e.to); } } } return dist; } void solve() { int n, m; cin >> n >> m; int X, Y; cin >> X >> Y; X--; Y--; vector<pair<double, double>> p(n), P(m); rep(i, n) cin >> p[i].first >> p[i].second; rep(i, m) cin >> P[i].first >> P[i].second; vector<vector<edge<double>>> g(n); rep(i, m) { P[i].first--; P[i].second--; double x = P[i].first; double y = P[i].second; double d = sqrt(pow(p[x].first - p[y].first, 2) + pow(p[x].second - p[y].second, 2)); g[x].eb(y, d); g[y].eb(x, d); } auto dd = dijkstra(g, X); cout << dd[Y] << endl; } int main() { ios::sync_with_stdio(false); cin.tie(0); cout << fixed << setprecision(15); solve(); return 0; }