mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2025-01-11 18:51:59 +00:00
P6770 [USACO05MAR]Checking an Alibi 不在场的证明
R54888422
This commit is contained in:
parent
c7791f11e2
commit
9a2b00f274
47
Luogu/problem/P6770/P6770.cpp
Normal file
47
Luogu/problem/P6770/P6770.cpp
Normal file
@ -0,0 +1,47 @@
|
||||
#include <bits/stdc++.h>
|
||||
|
||||
using namespace std;
|
||||
|
||||
int f, p, c, m, u, v, w, x, dist[505];
|
||||
bool vis[505];
|
||||
vector<pair<int, int>> g[505];
|
||||
priority_queue<int, vector<int>, greater<int>> ans;
|
||||
|
||||
void dijkstra() {
|
||||
memset(dist, 0x3f, sizeof(dist));
|
||||
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> q;
|
||||
dist[1] = 0;
|
||||
q.push(make_pair(0, 1));
|
||||
while (!q.empty()) {
|
||||
auto t = q.top();
|
||||
q.pop();
|
||||
if (vis[t.second]) continue;
|
||||
for (auto i : g[t.second]) {
|
||||
if (dist[i.first] > t.first + i.second) {
|
||||
dist[i.first] = t.first + i.second;
|
||||
q.push(make_pair(dist[i.first], i.first));
|
||||
}
|
||||
}
|
||||
vis[t.second] = true;
|
||||
}
|
||||
}
|
||||
|
||||
int main() {
|
||||
cin >> f >> p >> c >> m;
|
||||
for (int i = 1; i <= p; i++) {
|
||||
cin >> u >> v >> w;
|
||||
g[u].push_back(make_pair(v, w));
|
||||
g[v].push_back(make_pair(u, w));
|
||||
}
|
||||
dijkstra();
|
||||
for (int i = 1; i <= c; i++) {
|
||||
cin >> x;
|
||||
if (dist[x] <= m) ans.push(i);
|
||||
}
|
||||
cout << ans.size() << endl;
|
||||
while (!ans.empty()) {
|
||||
cout << ans.top() << endl;
|
||||
ans.pop();
|
||||
}
|
||||
return 0;
|
||||
}
|
Loading…
Reference in New Issue
Block a user