# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
307549 |
2020-09-28T15:13:31 Z |
HynDuf |
Ceste (COCI17_ceste) |
C++11 |
|
121 ms |
3700 KB |
#pragma GCC target ("sse4")
#include <bits/stdc++.h>
#define task "C"
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i <= (r); ++i)
#define Rep(i, r, l) for (int i = (r); i >= (l); --i)
#define DB(X) { cerr << #X << " = " << (X) << '\n'; }
#define DB1(A, _) { cerr << #A << "[" << _ << "] = " << (A[_]) << '\n'; }
#define DB2(A, _, __) { cerr << #A << "[" << _ << "][" << __ << "] = " << (A[_][__]) << '\n'; }
#define DB3(A, _, __, ___) { cerr << #A << "[" << _ << "][" << __ << "][" << ___ << "] = " << (A[_][__][___]) << '\n'; }
#define PR(A, l, r) { cerr << '\n'; rep(_, l, r) DB1(A, _); cerr << '\n';}
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back
#define pf push_front
#define F first
#define S second
#define by(x) [](const auto& a, const auto& b) { return a.x < b.x; } // sort(arr, arr + N, by(a));
#define next ___next
#define prev ___prev
#define y1 ___y1
#define left ___left
#define right ___right
#define y0 ___y0
#define div ___div
#define j0 ___j0
#define jn ___jn
using ll = long long;
using ld = long double;
using ull = unsigned long long;
using namespace std;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<ll> vl;
const int N = 2002;
int n, m, mnCost[N];
ll ans[N];
viii g[N];
int main()
{
#ifdef HynDuf
freopen(task".in", "r", stdin);
//freopen(task".out", "w", stdout);
#else
ios_base::sync_with_stdio(false); cin.tie(nullptr);
#endif
cin >> n >> m;
rep(i, 1, m)
{
int u, v, t, c;
cin >> u >> v >> t >> c;
g[u].pb({v, {t, c}});
g[v].pb({u, {t, c}});
}
fill(ans, ans + 1 + n, 1e18);
fill(mnCost, mnCost + 1 + n, 1e9);
priority_queue<iii, viii, greater<iii> > pq;
pq.push({0, {0, 1}});
ans[1] = 0;
while (!pq.empty())
{
int u = pq.top().S.S, t = pq.top().F, c = pq.top().S.F;
pq.pop();
if (c >= mnCost[u]) continue;
mnCost[u] = c;
ans[u] = min(ans[u], t * 1LL * c);
for (iii E : g[u]) if (c + E.S.S < mnCost[E.F])
pq.push({t + E.S.F, {c + E.S.S, E.F}});
}
rep(i, 2, n) cout << (ans[i] == 1e18 ? -1 : ans[i]) << '\n';
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
292 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
512 KB |
Output is correct |
2 |
Correct |
2 ms |
512 KB |
Output is correct |
3 |
Correct |
2 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
9 ms |
960 KB |
Output is correct |
2 |
Correct |
12 ms |
992 KB |
Output is correct |
3 |
Correct |
12 ms |
960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
87 ms |
1396 KB |
Output is correct |
2 |
Correct |
113 ms |
3700 KB |
Output is correct |
3 |
Correct |
3 ms |
612 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
640 KB |
Output is correct |
2 |
Correct |
109 ms |
2164 KB |
Output is correct |
3 |
Correct |
5 ms |
512 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
760 KB |
Output is correct |
2 |
Correct |
110 ms |
1452 KB |
Output is correct |
3 |
Correct |
94 ms |
1404 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
99 ms |
1404 KB |
Output is correct |
2 |
Correct |
90 ms |
1404 KB |
Output is correct |
3 |
Correct |
121 ms |
1404 KB |
Output is correct |