Submission #720229

# Submission time Handle Problem Language Result Execution time Memory
720229 2023-04-07T17:09:09 Z Ahmed57 Ceste (COCI17_ceste) C++14
16 / 160
1010 ms 131072 KB
#include <bits/stdc++.h>

using namespace std;
#define int long long
long long cost[201][40001];
vector<pair<int,pair<int,int>>> adj[201];
signed main(){
    int n,m;
    cin>>n>>m;
    for(int i = 0;i<=n;i++){
        for(int j = 1;j<=40000;j++){
            cost[i][j] = 1e9;
        }
    }
    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(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 = 1e18;
        for(long long j = 1;j<=10000;j++){
            ans = min(ans,j*cost[i][j]);
        }
        cout<<ans<<endl;
    }
}
# Verdict Execution time Memory Grader output
1 Correct 105 ms 3916 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 1010 ms 44320 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 538 ms 14152 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 976 ms 38212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 85 ms 128092 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 247 ms 131072 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 128100 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 82 ms 127904 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 83 ms 127980 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 87 ms 127916 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -