Submission #114314

#TimeUsernameProblemLanguageResultExecution timeMemory
114314MohamedAhmed04Ceste (COCI17_ceste)C++14
160 / 160
480 ms12948 KiB
#include <bits/stdc++.h> using namespace std; const int MAXN = 2010 , MAXT = MAXN * MAXN; struct edge { int to , time , cost ; edge(int ve , int ti , int co) { to = ve ; time = ti ; cost = co ; } }; vector< vector<edge> >adj(MAXN) ; long long ans[MAXN] , tillnow[MAXN] ; int n , m ; int main() { scanf("%d %d" , &n, &m) ; int a , b , c , d ; for(int i = 0 ; i < m ; ++i) { scanf("%d %d %d %d" , &a , &b , &c , &d) ; adj[a].push_back(edge(b , c , d)) ; adj[b].push_back(edge(a , c , d)) ; } long long cons = 1e17 ; for(int i = 1 ; i <= n ; ++i) ans[i] = cons , tillnow[i] = 1e17; priority_queue< pair<int , pair<int , int> > , vector< pair<int , pair<int , int> > > , greater< pair<int , pair<int , int> > > >q ; q.push({0 , {0 , 1}}) ; while(!q.empty()) { pair<int , pair<int , int> >p = q.top() ; q.pop() ; int node = p.second.second , sumc = p.first , sumt = p.second.first ; ans[node] = min(ans[node] , (sumt * 1ll) * (sumc * 1ll)) ; if(sumt > tillnow[node]) continue; tillnow[node] = sumt ; for(auto &child : adj[node]) { int nto = child.to ; int ntime = child.time + sumt; int ncost = child.cost + sumc; if(ntime >= MAXT) continue ; q.push({ncost , {ntime , nto}}) ; } } for(int i = 2 ; i <= n ; ++i) { if(ans[i] == cons) ans[i] = -1 ; printf("%lld\n" , ans[i]); } return 0 ; }

Compilation message (stderr)

ceste.cpp: In function 'int main()':
ceste.cpp:24:10: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     scanf("%d %d" , &n,  &m) ;
     ~~~~~^~~~~~~~~~~~~~~~~~~
ceste.cpp:28:14: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
         scanf("%d %d %d %d" , &a , &b , &c , &d) ;
         ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#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...