Submission #106696

#TimeUsernameProblemLanguageResultExecution timeMemory
106696amiCeste (COCI17_ceste)C++17
64 / 160
22 ms5120 KiB
#include <bits/stdc++.h> #define sz(c) int(c.size()) #define rep(i,a,b) for (int i=a; i<(b); ++i) #define per(i,a,b) for (int i=(b)-1; i>=(a); --i) using namespace std; using ll = long long; struct edge_t { int to,t,c; }; int const INF=int(1e9); int const MAXN=110; int const MAXT=110; int N,M; vector<edge_t> adj[MAXN]; int f[MAXN][MAXN*MAXT]; int res[MAXN]; int main() { cin.tie(0); ios_base::sync_with_stdio(0); cout<<fixed<<setprecision(10); cin>>N>>M; rep(i,0,M) { int u,v,t,c; cin>>u>>v>>t>>c; u--, v--; adj[u].push_back({v,t,c}); adj[v].push_back({u,t,c}); } rep(i,1,N) res[i]=INF; rep(i,0,N) rep(j,0,N*MAXT) f[i][j]=INF; f[0][0]=0; rep(t,0,N*MAXT) rep(v,0,N) if (f[v][t]!=INF) { int c=f[v][t]; res[v]=min(res[v],t*c); for (auto e:adj[v]) { int u=e.to, nt=t+e.t, nc=c+e.c; f[u][nt]=min(f[u][nt],nc); } } rep(i,1,N) if (res[i]==INF) cout<<"-1\n"; else cout<<res[i]<<"\n"; }
#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...