# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
599532 |
2022-07-19T15:16:15 Z |
pedroslrey |
Toll (BOI17_toll) |
C++17 |
|
55 ms |
6712 KB |
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 5e4 + 10;
vector<pair<int, int>> graph[MAXN];
int dist[MAXN];
bool marc[MAXN];
void dijkstra(int n) {
for (int i = 1; i < n; ++i)
dist[i] = 1e9;
set<pair<int, int>> s;
s.emplace(0, 0);
while (!s.empty()) {
int u = s.begin()->second; s.erase(s.begin());
if (marc[u]) continue;
marc[u] = true;
for (auto [v, c]: graph[u]) {
int d = dist[u] + c;
if (dist[v] > d) {
dist[v] = d;
s.emplace(d, v);
}
}
}
}
int main() {
ios_base::sync_with_stdio(false); cin.tie(NULL);
int n, q, m, k;
cin >> k >> n >> m >> q;
for (int i = 0; i < m; ++i) {
int u, v, t;
cin >> u >> v >> t;
graph[u].emplace_back(v, t);
}
dijkstra(n);
for (int i = 0; i < q; ++i) {
int a, b;
cin >> a >> b;
if (marc[b]) cout << dist[b] << "\n";
else cout << "-1\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
4308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
34 ms |
4812 KB |
Output is correct |
2 |
Correct |
1 ms |
1496 KB |
Output is correct |
3 |
Correct |
1 ms |
1492 KB |
Output is correct |
4 |
Correct |
1 ms |
1492 KB |
Output is correct |
5 |
Correct |
1 ms |
1500 KB |
Output is correct |
6 |
Correct |
1 ms |
1500 KB |
Output is correct |
7 |
Correct |
3 ms |
1620 KB |
Output is correct |
8 |
Correct |
4 ms |
1620 KB |
Output is correct |
9 |
Correct |
17 ms |
4072 KB |
Output is correct |
10 |
Correct |
55 ms |
6496 KB |
Output is correct |
11 |
Correct |
36 ms |
5052 KB |
Output is correct |
12 |
Correct |
24 ms |
4436 KB |
Output is correct |
13 |
Correct |
51 ms |
6712 KB |
Output is correct |
14 |
Correct |
40 ms |
4768 KB |
Output is correct |
15 |
Correct |
37 ms |
4100 KB |
Output is correct |
16 |
Correct |
26 ms |
4112 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1496 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
1496 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
19 ms |
4308 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |