結果
問題 |
No.1069 電柱 / Pole (Hard)
|
ユーザー |
![]() |
提出日時 | 2020-05-29 23:14:56 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,498 bytes |
コンパイル時間 | 1,901 ms |
コンパイル使用メモリ | 179,524 KB |
実行使用メモリ | 6,824 KB |
最終ジャッジ日時 | 2024-11-06 12:10:51 |
合計ジャッジ時間 | 14,571 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | WA * 2 RE * 2 |
other | WA * 5 RE * 74 |
ソースコード
#include<bits/stdc++.h> #define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i) #define rep(i,a,b) for(int i=int(a);i<int(b);++i) #define All(x) (x).begin(),(x).end() #define rAll(x) (x).rbegin(),(x).rend() using namespace std; using ll = long long; int main(){ int N,M,K; cin>>N>>M>>K; int X,Y; cin>>X>>Y; X--;Y--; vector<double> p(N),q(N); REP(i,N) cin>>p[i]>>q[i]; using P = pair<double,int> ; vector<vector<P>> graph(N); REP(i,M){ int a,b; cin>>a>>b; a--;b--; double c = sqrt(pow(p[a]-p[b],2) + pow(q[a]-q[b],2)); graph[a].push_back(P(c,b)); graph[b].push_back(P(c,a)); } const double INF=1LL<<40; vector<priority_queue<double>> dist(N); priority_queue<double,vector<double>,greater<double>> ans; dist[X].push(0); REP(i,N-1) REP(j,N){ if( dist[j].empty()) continue; REP(k,graph[j].size()){ int TO=graph[j][k].second; double COST=graph[j][k].first; while(!dist[j].empty()){ double now = dist[j].top();dist[j].pop(); if(dist[TO].size()<K || now + COST < dist[TO].top()){ dist[TO].push(now+COST); if(TO==Y) ans.push(now+COST); while(dist[TO].size()>K){ dist[TO].pop(); } } } } } while(K--){ printf("%.16f\n", ans.top()); ans.pop(); } }