# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
938785 |
2024-03-05T14:21:41 Z |
vjudge1 |
Toll (BOI17_toll) |
C++17 |
|
136 ms |
7868 KB |
#include <bits/stdc++.h>
#define int long long
#define ff first
#define ss second
using namespace std;
struct Edge {
int x, y, t;
Edge(int xi, int yi, int ti):x(xi),y(yi),t(ti){}
};
int k, n, m, q, x, y, t;
vector<vector<Edge>> graph;
signed main() {
cin >> k >> n >> m >> q;
graph = vector<vector<Edge>>(n);
for(int i = 0; i < m; i++) {
cin >> x >> y >> t;
graph[x].push_back(Edge(x, y, t));
}
priority_queue<pair<int,int>> pq;
vector<int> dist(n, LLONG_MAX);
pair<int,int> temp;
pq.push({0, 0});
while(pq.size()) {
temp = pq.top();
pq.pop();
temp.ff = -temp.ff;
//cout << temp.ff << " " << temp.ss << "\n";
if(dist[temp.ss] < temp.ff) continue;
dist[temp.ss] = temp.ff;
for(auto j : graph[temp.ss]) {
if(temp.ff + j.t < dist[j.y]) pq.push({-(temp.ff + j.t), j.y});
}
}
while(q--) {
cin >> x >> y;
if(dist[y] == LLONG_MAX) cout << "-1\n";
else cout << dist[y] << "\n";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
3416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
79 ms |
5192 KB |
Output is correct |
2 |
Correct |
1 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
0 ms |
348 KB |
Output is correct |
6 |
Correct |
0 ms |
348 KB |
Output is correct |
7 |
Correct |
15 ms |
500 KB |
Output is correct |
8 |
Correct |
16 ms |
572 KB |
Output is correct |
9 |
Correct |
46 ms |
3420 KB |
Output is correct |
10 |
Correct |
136 ms |
7252 KB |
Output is correct |
11 |
Correct |
98 ms |
5596 KB |
Output is correct |
12 |
Correct |
61 ms |
4528 KB |
Output is correct |
13 |
Correct |
108 ms |
7868 KB |
Output is correct |
14 |
Correct |
65 ms |
4944 KB |
Output is correct |
15 |
Correct |
55 ms |
3916 KB |
Output is correct |
16 |
Correct |
54 ms |
3956 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
52 ms |
3416 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |