# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
720238 |
2023-04-07T17:31:28 Z |
Ahmed57 |
Ceste (COCI17_ceste) |
C++14 |
|
503 ms |
64076 KB |
#include <bits/stdc++.h>
using namespace std;
#define int long long
long long cost[2005][2005];
vector<pair<int,pair<int,int>>> adj[201];
signed main(){
int n,m;
cin>>n>>m;
//if(n<=100)assert(0);
for(int i = 0;i<=n;i++){
for(int j = 1;j<=2004;j++){
cost[i][j] = 1e15;
}
}
for(int i = 0;i<m;i++){
int a,b,c,d;
cin>>a>>b>>c>>d;
adj[a].push_back({b,{c,d}});
adj[b].push_back({a,{c,d}});
}
priority_queue<pair<int,pair<int,int>>> q;
q.push({0,{0,1}});
cost[1][0]=0;
while(!q.empty()){
int no = q.top().second.second;
int se = q.top().second.first;
int co = -q.top().first;
q.pop();
if(cost[no][se]<co)continue;
for(auto j:adj[no]){
if(co+j.second.second>2004)continue;
if(cost[j.first][se+j.second.first]>co+j.second.second){
cost[j.first][se+j.second.first] = co+j.second.second;
q.push({-cost[j.first][se+j.second.first],{se+j.second.first,j.first}});
}
}
}
for(int i = 2;i<=n;i++){
long long ans = 1e15;
for(long long j = 1;j<=2004;j++){
ans = min(ans,j*cost[i][j]);
}
if(ans>=1e15){
cout<<"-1"<<endl;
}
else cout<<ans<<endl;
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
596 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
42 ms |
3532 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
27 ms |
2480 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
41 ms |
3532 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
28 ms |
42964 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
503 ms |
27088 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
42 ms |
64076 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
21 ms |
32208 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
22 ms |
32244 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
44 ms |
64032 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |