結果
| 問題 | No.1065 電柱 / Pole (Easy) | 
| コンテスト | |
| ユーザー |  mmn15277198 | 
| 提出日時 | 2022-05-02 16:46:32 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 461 ms / 2,000 ms | 
| コード長 | 1,447 bytes | 
| コンパイル時間 | 1,075 ms | 
| コンパイル使用メモリ | 104,004 KB | 
| 実行使用メモリ | 39,716 KB | 
| 最終ジャッジ日時 | 2024-07-01 20:36:12 | 
| 合計ジャッジ時間 | 12,213 ms | 
| ジャッジサーバーID (参考情報) | judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 46 | 
ソースコード
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <cmath>
#include <iomanip>
#include <set>
#include <cstdio>
#include <string>
using namespace std;
const long double inf = 1001001001001001001;
long double f(long double x1, long double y1, long double x2, long double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int main() {
  cout << fixed << setprecision(15);
  int n, m;
  cin >> n >> m;
  int x, y;
  cin >> x >> y;
  x--;
  y--;
  vector<long double> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  vector<vector<pair<long double, int> > > g(n);
  for (int i = 0; i < m; i++) {
    int p, q;
    cin >> p >> q;
    p--;
    q--;
    g[p].push_back(make_pair(f(a[p], b[p], a[q], b[q]), q));
    g[q].push_back(make_pair(f(a[p], b[p], a[q], b[q]), p));
  }
  vector<long double> d(n, -inf);
  priority_queue<pair<long double, int>, vector<pair<long double, int> >, greater<pair<long double, int> > > pq;
  pq.push(make_pair(0, x));
  while (!pq.empty()) {
    long double cost = pq.top().first;
    int v = pq.top().second;
    pq.pop();
    if (d[v] == -inf) {
      d[v] = cost;
      for (auto p : g[v]) {
        long double cost2 = p.first;
        int v2 = p.second;
        if (d[v2] == -inf) {
          pq.push(make_pair(cost + cost2, v2));
        }
      }
    }
  }
  cout << d[y] << endl;
  return 0;
}
            
            
            
        