Submission #162985

#TimeUsernameProblemLanguageResultExecution timeMemory
162985MinnakhmetovToll (BOI17_toll)C++14
7 / 100
3035 ms4600 KiB
#include <bits/stdc++.h> #define ll long long #define all(aaa) aaa.begin(), aaa.end() using namespace std; struct E { int a, b, w; }; const int N = 1e5 + 5, INF = 1e9; E e[N]; int d[N]; signed main() { ios_base::sync_with_stdio(0); cin.tie(NULL); int n, m, k, o; cin >> k >> n >> m >> o; for (int i = 0; i < m; i++) { cin >> e[i].a >> e[i].b >> e[i].w; } sort(e, e + m, [](E x, E y) { return x.a < y.a; }); for (int i = 0; i < o; i++) { int x, y; cin >> x >> y; fill(d, d + n, INF); d[x] = 0; for (int j = 0; j < m; j++) { d[e[j].b] = min(d[e[j].b], d[e[j].a] + e[j].w); } if (d[y] == INF) cout << "-1\n"; else cout << d[y] << "\n"; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...