# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
56171 |
2018-07-10T07:25:14 Z |
노영훈(#1580) |
Cities (BOI16_cities) |
C++11 |
|
591 ms |
19088 KB |
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MX=100010, inf=2e9;
const ll linf=2e18;
struct edge{
int to; ll co;
bool operator < (const edge &e) const {
return co>e.co;
}
};
vector<edge> G0[MX];
int n, m, k;
int A[6];
ll dist[6][MX];
ll solve3(){
ll ans=linf;
for(int i=1; i<=n; i++){
ll now=0;
for(int j=1; j<=k; j++) now+=dist[j][i];
ans=min(ans, now);
}
return ans;
}
ll solve4(){
return 0;
}
ll solve5(){
return 0;
}
int main(){
ios::sync_with_stdio(0); cin.tie(0);
cin>>n>>k>>m;
for(int i=1; i<=k; i++) cin>>A[i];
for(int i=1; i<=m; i++){
int u,v,c; cin>>u>>v>>c;
G0[u].push_back({v,c});
G0[v].push_back({u,c});
}
for(int i=1; i<=k; i++){
int st=A[i];
ll *D=dist[i];
for(int i=1; i<=n; i++) D[i]=linf;
priority_queue<edge> Q;
D[st]=0; Q.push({st, 0});
while(!Q.empty()){
int v=Q.top().to; ll d=Q.top().co; Q.pop();
if(D[v]!=d) continue;
for(edge &e:G0[v]){
int x=e.to; ll c=e.co;
if(d+c>=D[x]) continue;
D[x]=d+c; Q.push({x,D[x]});
}
}
// for(int i=1; i<=n; i++) cout<<D[i]<<' ';
// cout<<'\n';
}
if(k<=3) cout<<solve3();
else if(k<=4) cout<<solve4();
else cout<<solve5();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
2680 KB |
Output is correct |
2 |
Correct |
4 ms |
2832 KB |
Output is correct |
3 |
Correct |
5 ms |
2832 KB |
Output is correct |
4 |
Incorrect |
4 ms |
2948 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
366 ms |
17448 KB |
Output is correct |
2 |
Correct |
374 ms |
18056 KB |
Output is correct |
3 |
Correct |
181 ms |
18056 KB |
Output is correct |
4 |
Correct |
113 ms |
18056 KB |
Output is correct |
5 |
Correct |
342 ms |
18056 KB |
Output is correct |
6 |
Correct |
86 ms |
18056 KB |
Output is correct |
7 |
Correct |
7 ms |
18056 KB |
Output is correct |
8 |
Correct |
6 ms |
18056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
8 ms |
18056 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
525 ms |
18372 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
591 ms |
19088 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |