# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
106696 |
2019-04-19T17:43:41 Z |
ami |
Ceste (COCI17_ceste) |
C++17 |
|
22 ms |
5120 KB |
#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 time |
Memory |
Grader output |
1 |
Correct |
3 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
22 ms |
5120 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
7 ms |
1024 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
19 ms |
5112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
4 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
11 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
640 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
3 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |