結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー どららどらら
提出日時 2020-05-29 21:58:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 1,453 bytes
コンパイル時間 2,286 ms
コンパイル使用メモリ 172,220 KB
実行使用メモリ 20,852 KB
最終ジャッジ日時 2024-04-23 22:17:43
合計ジャッジ時間 11,029 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
6,812 KB
testcase_01 AC 3 ms
6,940 KB
testcase_02 AC 174 ms
12,536 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 AC 67 ms
9,204 KB
testcase_08 RE -
testcase_09 AC 23 ms
7,236 KB
testcase_10 AC 111 ms
11,512 KB
testcase_11 AC 73 ms
9,460 KB
testcase_12 AC 72 ms
11,640 KB
testcase_13 AC 193 ms
15,580 KB
testcase_14 AC 215 ms
17,400 KB
testcase_15 RE -
testcase_16 AC 138 ms
13,992 KB
testcase_17 RE -
testcase_18 AC 99 ms
12,688 KB
testcase_19 RE -
testcase_20 AC 67 ms
9,640 KB
testcase_21 AC 125 ms
13,832 KB
testcase_22 RE -
testcase_23 AC 5 ms
6,944 KB
testcase_24 AC 7 ms
6,940 KB
testcase_25 AC 64 ms
10,284 KB
testcase_26 AC 140 ms
13,480 KB
testcase_27 AC 153 ms
13,984 KB
testcase_28 AC 250 ms
20,852 KB
testcase_29 AC 37 ms
8,328 KB
testcase_30 RE -
testcase_31 AC 166 ms
15,376 KB
testcase_32 AC 114 ms
11,732 KB
testcase_33 RE -
testcase_34 AC 98 ms
12,480 KB
testcase_35 RE -
testcase_36 AC 5 ms
6,940 KB
testcase_37 AC 5 ms
6,944 KB
testcase_38 AC 5 ms
6,944 KB
testcase_39 AC 6 ms
6,940 KB
testcase_40 AC 4 ms
6,940 KB
testcase_41 RE -
testcase_42 AC 97 ms
9,972 KB
testcase_43 RE -
testcase_44 AC 62 ms
8,500 KB
testcase_45 RE -
testcase_46 AC 3 ms
6,944 KB
testcase_47 AC 3 ms
6,940 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

#define MAX_N 100005
struct Edge {
  int src, dest;
  double weight;
};
bool operator>(const Edge& a, const Edge& b){
  return a.weight > b.weight;
}
int N, M;
vector<Edge> G[MAX_N];
double cost[MAX_N];

void dijkstra(int start){
  rep(i,N+1){
    cost[i] = 1e100;
  }
  priority_queue<Edge,vector<Edge>,greater<Edge>> q;
  q.push((Edge){-1,start,0});

  while(!q.empty()){
    Edge e=q.top();
    q.pop();
    if(cost[e.dest] < 1e99) continue;
    cost[e.dest]=e.weight;
    FOR(it,G[e.dest])
      if(cost[it->dest] > 1e99) q.push((Edge){it->src,it->dest,e.weight+it->weight});
  }
}

int main(){
  cin >> N >> M;
  int X, Y;
  cin >> X >> Y;
  vector<pair<int,int>> v;
  v.emplace_back(0,0);
  rep(i,N){
    int p, q;
    cin >> p >> q;
    v.emplace_back(p,q);
  }
  rep(i,M){
    int p, q;
    cin >> p >> q;

    double px = v[p].first;
    double py = v[p].second;
    double qx = v[q].first;
    double qy = v[q].second;
    double dist = sqrt((px-qx)*(px-qx) + (py-qy)*(py-qy));
    G[p].push_back((Edge){p,q,dist});
    G[q].push_back((Edge){q,p,dist});
  }

  dijkstra(X);
  double ret = cost[Y];
  printf("%.12lf\n", ret);
  
  return 0;
}
0