# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
651926 |
2022-10-20T14:18:25 Z |
longvu |
Ceste (COCI17_ceste) |
C++14 |
|
691 ms |
131072 KB |
/**
* author: longvu
* created: 10/20/22 21:00:44
**/
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sz(x) ((int)x.size())
#define all(x) (x).begin(), (x).end()
const int INF = numeric_limits<int>::max();
const int naxn = (int)(209);
const int naxval = (int)(20009);
const int mod = 1e9 + 7;
template<class X, class Y>
bool maximize(X& x, const Y y) {
if (y > x) {x = y; return true;}
return false;
}
template<class X, class Y>
bool minimize(X& x, const Y y) {
if (y < x) {x = y; return true;}
return false;
}
struct Node {
int lab, t, c;
};
vector<Node> adj[naxn];
int dp[naxn][naxval];
int32_t main() {
ios_base::sync_with_stdio(false);
cin.tie(0);
int n, m;
cin >> n >> m;
for (int i = 1; i <= m; ++i) {
int u, v, t, c;
cin >> u >> v >> t >> c;
adj[u].push_back({v, t, c});
adj[v].push_back({u, t, c});
}
priority_queue<tuple<int, int, int>, vector<tuple<int, int, int>>, greater<tuple<int, int, int>>> pq;
memset(dp, 0x3f, sizeof dp);
dp[1][0] = 0;
pq.push({0, 1 , 0});
while (!pq.empty()) {
tuple<int, int, int> u = pq.top();
pq.pop();
for (auto v : adj[get<1>(u)]) {
if (get<2>(u) + v.t < naxval
&& minimize(dp[v.lab][get<2>(u) + v.t], v.c + get<0>(u))) {
pq.push({v.c + get<0>(u), v.lab, get<2>(u) + v.t});
}
}
}
for (int i = 2; i <= n; ++i) {
int ans = INF;
for (int j = 0; j < naxval; ++j) {
if (dp[i][j] < naxval) {
minimize(ans, j * dp[i][j]);
}
}
cout << (ans < naxval ? ans : -1) << '\n';
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
72 ms |
33168 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
406 ms |
39440 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
303 ms |
36296 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
305 ms |
36212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
1 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
691 ms |
131072 KB |
Execution killed with signal 9 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
436 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
2 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |