結果
| 問題 |
No.1069 電柱 / Pole (Hard)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2020-05-30 00:13:38 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
MLE
|
| 実行時間 | - |
| コード長 | 2,095 bytes |
| コンパイル時間 | 2,039 ms |
| コンパイル使用メモリ | 181,692 KB |
| 実行使用メモリ | 813,940 KB |
| 最終ジャッジ日時 | 2024-11-06 12:17:09 |
| 合計ジャッジ時間 | 5,497 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | MLE * 1 -- * 78 |
ソースコード
#include <bits/stdc++.h>
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
using namespace std;
using ll = double;
constexpr char newl = '\n';
struct State {
int at;
ll cost;
bitset<2000> vis;
State(int at, ll cost) : at(at), cost(cost) {}
bool operator>(const State& s) const {
return cost > s.cost;
}
};
struct Edge {
int to;
ll cost;
Edge(int to, ll cost) : to(to), cost(cost) {}
};
using Graph = vector< vector<Edge> >; //隣接リスト
const ll INF = 1e15;
//const int NONE = -1;
//sは始点、mincは最短経路のコスト、prevsは最短経路をたどる際の前の頂点
void dijkstra(int s, int t, const Graph& graph, int K){
const int n = graph.size();
vector< vector<ll> > minc(n);
priority_queue<State, vector<State>, greater<State> > pq;
{
State hoge(s, 0);
hoge.vis.set(s);
pq.push(move(hoge));
}
while(!pq.empty()) {
State cur = pq.top();
pq.pop();
if (minc[cur.at].size() < K) minc[cur.at].push_back(cur.cost);
if (minc[t].size() >= K) break;
for(const Edge& e : graph[cur.at]) {
if (cur.vis[e.to]) continue;
ll cost = cur.cost + e.cost;
State nex(cur);
nex.vis.set(e.to);
nex.at = e.to;
nex.cost = cost;
pq.push(move(nex));
}
}
for (int i = 0; i < K; i++) {
cout << fixed << setprecision(15) << (i >= minc[t].size() ? -1 : minc[t][i]) << newl;
}
}
int main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
int n, m, K;
cin >> n >> m >> K;
int x, y;
cin >> x >> y;
--x; --y;
vector<int> p(n), q(n);
for (int i = 0; i < n; i++) {
cin >> p[i] >> q[i];
}
Graph g(n);
for (int i = 0; i < m; i++) {
int u, v;
cin >> u >> v;
--u; --v;
ll cost = hypot(p[u] - p[v], q[u] - q[v]);
g[u].emplace_back(v, cost);
g[v].emplace_back(u, cost);
}
dijkstra(x, y, g, K);
return 0;
}