# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
641959 |
2022-09-18T03:23:11 Z |
makanhulia |
Cities (BOI16_cities) |
C++17 |
|
6000 ms |
24904 KB |
#include <bits/stdc++.h>
#define mp make_pair
#define int long long
#define pb push_back
#define STC stack <int>
#define pii pair <int, int>
#define vi vector <int>
#define vii vector <vi >
#define se second
#define fi first
using namespace std;
const int mod = 1e9 + 7;
const int MxN = 1e9 + 7;
signed main(){
ios_base::sync_with_stdio(false);
cout.tie(0);
cin.tie(NULL);
int n, k, m; cin >> n >> k >> m;
vi P(k);
vector <vector <pii>> N(n + 1);
for(int i = 0; i < k; i++) cin >> P[i];
for(int i = 0; i < m; i++){
int a, b, c; cin >> a >> b >> c;
N[a].pb({b, c});
N[b].pb({a, c});
}
int ans = LLONG_MAX;
for(int i = 1; i <= n; i++){
priority_queue <pii, vector <pii>, greater <pii>> Q;
Q.push({0, i});
vi V(n+1, 1e18);
while(Q.size()){
int val = Q.top().fi, cur = Q.top().se;
Q.pop();
if(V[cur] < val) continue;
V[cur] = val;
for(auto it : N[cur]){
Q.push({val + it.se, it.fi});
}
}
int sum = 0;
for(int j = 0; j < k; j++) sum += V[P[j]];
ans = min(ans, sum);
}
cout << ans << "\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
324 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6089 ms |
24828 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
354 ms |
536 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6084 ms |
24808 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
6028 ms |
24904 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |