mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-12-28 14:11:58 +00:00
parent
65fadfdd85
commit
21f4c7d755
77
BZOJ/2763/2763.cpp
Normal file
77
BZOJ/2763/2763.cpp
Normal file
@ -0,0 +1,77 @@
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <iostream>
|
||||
#include <queue>
|
||||
#include <vector>
|
||||
|
||||
using std::cin;
|
||||
using std::cout;
|
||||
const char endl = '\n';
|
||||
|
||||
const int N = 10005;
|
||||
|
||||
int n, m, k, s, t;
|
||||
std::vector<std::pair<int, int>> g[N << 4];
|
||||
|
||||
int dist[N << 4];
|
||||
bool vis[N << 4];
|
||||
|
||||
void dijkstra() {
|
||||
memset(dist, 0x3f, sizeof(dist));
|
||||
memset(vis, 0x00, sizeof(vis));
|
||||
|
||||
std::priority_queue<std::pair<int, int>, std::vector<std::pair<int, int>>, std::greater<std::pair<int, int>>> q;
|
||||
|
||||
q.push(std::make_pair(0, s));
|
||||
dist[s] = 0;
|
||||
|
||||
while (!q.empty()) {
|
||||
auto t = q.top();
|
||||
q.pop();
|
||||
|
||||
if (vis[t.second]) continue;
|
||||
|
||||
for (auto e : g[t.second]) {
|
||||
int v = e.first,
|
||||
w = e.second;
|
||||
|
||||
if (dist[v] > t.first + w) {
|
||||
dist[v] = t.first + w;
|
||||
|
||||
q.push(std::make_pair(dist[v], v));
|
||||
}
|
||||
}
|
||||
|
||||
vis[t.second] = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
std::ios::sync_with_stdio(false);
|
||||
|
||||
cin >> n >> m >> k >> s >> t;
|
||||
|
||||
for (int i = 1, u, v, w; i <= m; i++) {
|
||||
cin >> u >> v >> w;
|
||||
|
||||
g[u].push_back(std::make_pair(v, w));
|
||||
g[v].push_back(std::make_pair(u, w));
|
||||
|
||||
for (int j = 1; j <= k; j++) {
|
||||
g[u + (j - 1) * n].push_back(std::make_pair(v + j * n, 0));
|
||||
g[v + (j - 1) * n].push_back(std::make_pair(u + j * n, 0));
|
||||
g[u + j * n].push_back(std::make_pair(v + j * n, w));
|
||||
g[v + j * n].push_back(std::make_pair(u + j * n, w));
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 1; i <= k; i++) {
|
||||
g[t + (i - 1) * n].push_back(std::make_pair(t + i * n, 0));
|
||||
}
|
||||
|
||||
dijkstra();
|
||||
|
||||
cout << dist[t + n * k] << endl;
|
||||
|
||||
return 0;
|
||||
}
|
BIN
BZOJ/2763/data/1.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/1.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/1.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/1.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/10.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/10.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/10.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/10.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/2.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/2.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/2.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/3.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/3.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/3.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/3.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/4.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/4.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/4.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/4.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/5.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/5.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/5.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/5.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/6.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/6.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/6.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/6.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/7.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/7.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/7.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/7.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/8.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/8.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/8.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/8.out
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/9.in
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/9.in
(Stored with Git LFS)
Normal file
Binary file not shown.
BIN
BZOJ/2763/data/9.out
(Stored with Git LFS)
Normal file
BIN
BZOJ/2763/data/9.out
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user