# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
236776 |
2020-06-03T09:38:01 Z |
VEGAnn |
Ceste (COCI17_ceste) |
C++14 |
|
15 ms |
4352 KB |
#include <bits/stdc++.h>
#define PB push_back
#define sz(x) ((int)x.size())
#define ft first
#define sd second
using namespace std;
typedef long long ll;
const int N = 110;
const int MX = 10010;
const int oo = 2e9;
const ll OO = 1e18;
const int md = int(1e9) + 7;
vector<int> g[N];
int n, m, ans[N], f[N][MX], A[N], B[N], C[N], T[N];
int main(){
ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef _LOCAL
freopen("in.txt","r",stdin);
#endif // _LOCAL
cin >> n >> m;
for (int i = 0; i < m; i++){
cin >> A[i] >> B[i] >> T[i] >> C[i];
A[i]--; B[i]--;
g[A[i]].PB(i);
g[B[i]].PB(i);
}
for (int i = 0; i < n; i++){
ans[i] = oo;
for (int j = 0; j < MX; j++)
f[i][j] = oo;
}
f[0][0] = 0;
for (int tim = 1; tim < MX; tim++){
for (int v = 0; v < n; v++) {
for (int id : g[v]){
int u = (A[id] == v ? B[id] : A[id]);
int ot = tim - T[id];
if (ot < 0) continue;
if (f[u][ot] == oo) continue;
f[v][tim] = min(f[v][tim], f[u][ot] + C[id]);
}
if (f[v][tim] == oo) continue;
ans[v] = min(ans[v], f[v][tim] * tim);
}
}
for (int i = 1; i < n; i++)
cout << (ans[i] == oo ? -1 : ans[i]) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
768 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
12 ms |
1664 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
15 ms |
4352 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
5 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 |
6 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 |
5 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 |
8 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 |
6 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 |
5 ms |
512 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
2 |
Halted |
0 ms |
0 KB |
- |