# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
217490 |
2020-03-30T02:35:51 Z |
Fischer |
Ceste (COCI17_ceste) |
C++17 |
|
7 ms |
640 KB |
#include <bits/stdc++.h>
#define eb emplace_back
#define re(x, y, z) for (int x=y; x<z; ++x)
#define trav(v, x) for (auto v : x)
using namespace std;
using vi = vector<int>;
using ll = long long;
using vll = vector<ll>;
using iii = pair<pair<int, int>, int>;
const int maxn = 2e3 + 10;
struct Node {
int to, t, c;
Node() {}
Node(int to, int t, int c):
to(to), t(t), c(c) {}
};
vector<Node> g[maxn];
int n, m;
vll dikjstra(int s) {
priority_queue<iii, vector<iii>, greater<iii>> Q;
vll res(n+1, LLONG_MAX);
vi tim(n+1, INT_MAX);
Q.push({{0, 0}, s});
while (!Q.empty()) {
auto q = Q.top(); Q.pop();
int v = q.second;
int t = q.first.first, c = q.first.second;
res[v] = min(res[v], t*1ll*c);
if (tim[v] < t) continue;
else tim[v] = t;
trav(e, g[v]) {
assert(e.t > 0);
Q.push({{t+e.t, c+e.c}, e.to});
}
}
for (int i = 1; i <= n; ++i) {
if (res[i] == LLONG_MAX) res[i] = -1;
}
return res;
}
int main() {
scanf("%d%d", &n, &m);
for (int i = 0; i < m; ++i) {
int a, b, t, c;
scanf("%d%d%d%d", &a, &b, &t, &c);
g[a].eb(b, t, c);
g[b].eb(a, t, c);
}
vll res = dikjstra(1);
for (int i = 2; i <= n; ++i) {
printf("%lld\n", res[i]);
}
return 0;
}
Compilation message
ceste.cpp: In function 'int main()':
ceste.cpp:44:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d", &n, &m);
~~~~~^~~~~~~~~~~~~~~~
ceste.cpp:47:8: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
scanf("%d%d%d%d", &a, &b, &t, &c);
~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
7 ms |
640 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
6 ms |
512 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |