답안 #749053

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
749053 2023-05-27T09:35:02 Z onebit1024 Ceste (COCI17_ceste) C++17
0 / 160
434 ms 6728 KB
#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define all(c) c.begin(), c.end()
#define endl "\n"

const double PI=3.141592653589;


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define dbg(x...) cerr << "LINE(" << __LINE__ << ") -> " <<"[" << #x << "] = ["; _print(x)
#else
#define dbg(x...)
#endif

struct node{
    int v,t,c;
};

void solve()
{
    int n,m;
    cin >> n >> m;
    vector<vector<node>>adj(n+1);
    for(int i = 1;i<=m;++i){
        int u,v,b,d; // t,c
        cin >> u >> v >> b >> d;
        adj[u].pb({v,b,d});
        adj[v].pb({u,b,d});
    }
    priority_queue<vector<int>,vector<vector<int>>,greater<vector<int>>>pq;
    vector<int>res(n+1,1e18);
    res[1] = 0;
    int mm = 2000*3000;
    pq.push({0,0,1});
    vector<int>maxt(n+1,1e18);
    while(!pq.empty()){
        int u = pq.top()[2], c = pq.top()[0],t = pq.top()[1];
        res[u] = min(res[u], c*t);
        pq.pop();
        if(t>maxt[u])continue;
        maxt[u] = t;
        for(auto &[v,T,C] : adj[u]){
            int nc = C+c,nt = T+t;
            if(nt>mm)continue;
            pq.push({nc,nt,v});
        }
    }
    for(int i = 1;i<=n;++i){
        if(res[i]>=1e18)res[i] = -1;
        cout << res[i] << endl;
    }
}   

int32_t main()
{

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    

    int T=1;
    for(int i = 1;i<=T;++i)
    {
        // cout << "Case #" << i << ": ";
        solve();
    }
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 340 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 468 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 55 ms 2852 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 301 ms 5596 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 99 ms 1800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 402 ms 1748 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 434 ms 6728 KB Output isn't correct
2 Halted 0 ms 0 KB -