# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
162986 |
2019-11-10T16:00:32 Z |
Minnakhmetov |
Toll (BOI17_toll) |
C++14 |
|
3000 ms |
4856 KB |
#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 = 1e6 + 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 time |
Memory |
Grader output |
1 |
Correct |
2158 ms |
1500 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
7 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
376 KB |
Output is correct |
8 |
Correct |
2069 ms |
1500 KB |
Output is correct |
9 |
Correct |
1960 ms |
1416 KB |
Output is correct |
10 |
Correct |
249 ms |
744 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
3041 ms |
1948 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
42 ms |
1116 KB |
Output is correct |
11 |
Correct |
75 ms |
1660 KB |
Output is correct |
12 |
Correct |
106 ms |
2448 KB |
Output is correct |
13 |
Correct |
118 ms |
4728 KB |
Output is correct |
14 |
Correct |
90 ms |
3704 KB |
Output is correct |
15 |
Correct |
60 ms |
2552 KB |
Output is correct |
16 |
Correct |
59 ms |
2552 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
3 ms |
376 KB |
Output is correct |
7 |
Correct |
3 ms |
376 KB |
Output is correct |
8 |
Correct |
5 ms |
376 KB |
Output is correct |
9 |
Correct |
5 ms |
376 KB |
Output is correct |
10 |
Correct |
42 ms |
1116 KB |
Output is correct |
11 |
Correct |
75 ms |
1660 KB |
Output is correct |
12 |
Correct |
106 ms |
2448 KB |
Output is correct |
13 |
Correct |
118 ms |
4728 KB |
Output is correct |
14 |
Correct |
90 ms |
3704 KB |
Output is correct |
15 |
Correct |
60 ms |
2552 KB |
Output is correct |
16 |
Correct |
59 ms |
2552 KB |
Output is correct |
17 |
Correct |
1123 ms |
3308 KB |
Output is correct |
18 |
Correct |
2 ms |
376 KB |
Output is correct |
19 |
Correct |
2 ms |
376 KB |
Output is correct |
20 |
Correct |
2 ms |
380 KB |
Output is correct |
21 |
Correct |
2 ms |
376 KB |
Output is correct |
22 |
Correct |
2 ms |
376 KB |
Output is correct |
23 |
Correct |
15 ms |
476 KB |
Output is correct |
24 |
Correct |
26 ms |
504 KB |
Output is correct |
25 |
Correct |
48 ms |
504 KB |
Output is correct |
26 |
Correct |
39 ms |
504 KB |
Output is correct |
27 |
Correct |
636 ms |
2040 KB |
Output is correct |
28 |
Correct |
1559 ms |
4516 KB |
Output is correct |
29 |
Correct |
1716 ms |
4856 KB |
Output is correct |
30 |
Correct |
1393 ms |
3960 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2158 ms |
1500 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
6 ms |
376 KB |
Output is correct |
6 |
Correct |
7 ms |
376 KB |
Output is correct |
7 |
Correct |
6 ms |
376 KB |
Output is correct |
8 |
Correct |
2069 ms |
1500 KB |
Output is correct |
9 |
Correct |
1960 ms |
1416 KB |
Output is correct |
10 |
Correct |
249 ms |
744 KB |
Output is correct |
11 |
Execution timed out |
3041 ms |
1948 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |