Submission #749055

#TimeUsernameProblemLanguageResultExecution timeMemory
749055onebit1024Ceste (COCI17_ceste)C++17
160 / 160
1901 ms41484 KiB
#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 = 2;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(); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...