結果

問題 No.1065 電柱 / Pole (Easy)
ユーザー pionepione
提出日時 2020-05-29 23:03:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 167 ms / 2,000 ms
コード長 2,468 bytes
コンパイル時間 1,794 ms
コンパイル使用メモリ 176,004 KB
実行使用メモリ 20,752 KB
最終ジャッジ日時 2024-04-24 00:48:51
合計ジャッジ時間 7,206 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
8,488 KB
testcase_01 AC 5 ms
9,792 KB
testcase_02 AC 75 ms
14,916 KB
testcase_03 AC 110 ms
20,428 KB
testcase_04 AC 108 ms
19,816 KB
testcase_05 AC 83 ms
20,024 KB
testcase_06 AC 81 ms
19,816 KB
testcase_07 AC 28 ms
11,156 KB
testcase_08 AC 99 ms
18,880 KB
testcase_09 AC 12 ms
9,592 KB
testcase_10 AC 45 ms
13,252 KB
testcase_11 AC 33 ms
12,228 KB
testcase_12 AC 20 ms
10,180 KB
testcase_13 AC 77 ms
15,616 KB
testcase_14 AC 87 ms
17,688 KB
testcase_15 AC 108 ms
18,796 KB
testcase_16 AC 55 ms
12,996 KB
testcase_17 AC 129 ms
18,920 KB
testcase_18 AC 38 ms
11,716 KB
testcase_19 AC 110 ms
18,720 KB
testcase_20 AC 31 ms
11,040 KB
testcase_21 AC 43 ms
12,096 KB
testcase_22 AC 96 ms
17,660 KB
testcase_23 AC 5 ms
8,860 KB
testcase_24 AC 5 ms
8,712 KB
testcase_25 AC 18 ms
9,996 KB
testcase_26 AC 58 ms
14,280 KB
testcase_27 AC 56 ms
13,440 KB
testcase_28 AC 100 ms
17,856 KB
testcase_29 AC 14 ms
10,180 KB
testcase_30 AC 115 ms
18,316 KB
testcase_31 AC 77 ms
17,036 KB
testcase_32 AC 47 ms
13,572 KB
testcase_33 AC 121 ms
20,752 KB
testcase_34 AC 42 ms
12,144 KB
testcase_35 AC 113 ms
18,156 KB
testcase_36 AC 4 ms
8,644 KB
testcase_37 AC 5 ms
8,724 KB
testcase_38 AC 5 ms
8,588 KB
testcase_39 AC 5 ms
8,772 KB
testcase_40 AC 4 ms
9,796 KB
testcase_41 AC 167 ms
19,884 KB
testcase_42 AC 43 ms
11,968 KB
testcase_43 AC 78 ms
14,644 KB
testcase_44 AC 31 ms
11,204 KB
testcase_45 AC 75 ms
14,224 KB
testcase_46 AC 4 ms
9,668 KB
testcase_47 AC 4 ms
8,900 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using tll = tuple<ll,ll,ll>;
using vtll = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 10000;
const ll LINF = 1e18;

vll G[200100];
double dist[200100];

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  ll n,m; cin>>n>>m;
  ll x,y; cin>>x>>y; x--,y--;
  vpll P(n);
  rep(i,n){
    ll a,b; cin>>a>>b;
    P[i]={a,b};
  }
  
  rep(i,m){
    ll a,b; cin>>a>>b; a--,b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  
  fill(dist,dist+n,LINF);
  
  priority_queue<pair<double,ll>, vector<pair<double,ll>>, greater<pair<double,ll>>> q;
  q.emplace(0,x);
  dist[x]=0;
  
  while(!q.empty()){
    auto p=q.top(); q.pop();
    ll v=p.second; double c=p.first;
    if(dist[v]<c) continue;
    for(auto nv: G[v]){
      double span=sqrt((P[v].first-P[nv].first)*(P[v].first-P[nv].first)+(P[v].second-P[nv].second)*(P[v].second-P[nv].second));
      if(chmin(dist[nv],dist[v]+span)){
        q.emplace(dist[nv],nv);
      }
    }
  }
  
  cout<<std::setprecision(10)<<dist[y]<<endl;
  
}
0