# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
162987 |
2019-11-10T16:03:03 Z |
Minnakhmetov |
Toll (BOI17_toll) |
C++14 |
|
3000 ms |
30044 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], ans[N];
vector<pair<int, int>> v[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;
v[x].push_back({y, i});
}
for (int i = 0; i < n; i++) {
if (!v[i].empty()) {
fill(d, d + n, INF);
d[i] = 0;
for (int j = 0; j < m; j++) {
d[e[j].b] = min(d[e[j].b], d[e[j].a] + e[j].w);
}
for (auto p : v[i]) {
if (d[p.first] == INF)
ans[p.second] = -1;
else
ans[p.second] = d[p.first];
}
}
}
for (int i = 0; i < o; i++) {
cout << ans[i] << "\n";
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1851 ms |
25080 KB |
Output is correct |
2 |
Correct |
24 ms |
23800 KB |
Output is correct |
3 |
Correct |
26 ms |
23800 KB |
Output is correct |
4 |
Correct |
24 ms |
23800 KB |
Output is correct |
5 |
Correct |
27 ms |
24056 KB |
Output is correct |
6 |
Correct |
27 ms |
23928 KB |
Output is correct |
7 |
Correct |
28 ms |
23932 KB |
Output is correct |
8 |
Correct |
1927 ms |
25080 KB |
Output is correct |
9 |
Correct |
1749 ms |
25080 KB |
Output is correct |
10 |
Correct |
240 ms |
24440 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
67 ms |
25464 KB |
Output is correct |
2 |
Correct |
24 ms |
23800 KB |
Output is correct |
3 |
Correct |
57 ms |
23868 KB |
Output is correct |
4 |
Correct |
25 ms |
23928 KB |
Output is correct |
5 |
Correct |
25 ms |
23928 KB |
Output is correct |
6 |
Correct |
25 ms |
23800 KB |
Output is correct |
7 |
Correct |
28 ms |
24228 KB |
Output is correct |
8 |
Correct |
30 ms |
24240 KB |
Output is correct |
9 |
Correct |
49 ms |
25720 KB |
Output is correct |
10 |
Correct |
85 ms |
28280 KB |
Output is correct |
11 |
Correct |
70 ms |
27280 KB |
Output is correct |
12 |
Correct |
60 ms |
26488 KB |
Output is correct |
13 |
Correct |
87 ms |
28268 KB |
Output is correct |
14 |
Correct |
61 ms |
26616 KB |
Output is correct |
15 |
Correct |
57 ms |
26232 KB |
Output is correct |
16 |
Correct |
56 ms |
26176 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23800 KB |
Output is correct |
2 |
Correct |
24 ms |
23800 KB |
Output is correct |
3 |
Correct |
25 ms |
23928 KB |
Output is correct |
4 |
Correct |
25 ms |
23800 KB |
Output is correct |
5 |
Correct |
25 ms |
23800 KB |
Output is correct |
6 |
Correct |
26 ms |
23800 KB |
Output is correct |
7 |
Correct |
27 ms |
23928 KB |
Output is correct |
8 |
Correct |
28 ms |
23928 KB |
Output is correct |
9 |
Correct |
27 ms |
23928 KB |
Output is correct |
10 |
Correct |
65 ms |
24668 KB |
Output is correct |
11 |
Correct |
101 ms |
25140 KB |
Output is correct |
12 |
Correct |
131 ms |
25748 KB |
Output is correct |
13 |
Correct |
142 ms |
25888 KB |
Output is correct |
14 |
Correct |
242 ms |
25340 KB |
Output is correct |
15 |
Correct |
82 ms |
24824 KB |
Output is correct |
16 |
Correct |
83 ms |
24952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
24 ms |
23800 KB |
Output is correct |
2 |
Correct |
24 ms |
23800 KB |
Output is correct |
3 |
Correct |
25 ms |
23928 KB |
Output is correct |
4 |
Correct |
25 ms |
23800 KB |
Output is correct |
5 |
Correct |
25 ms |
23800 KB |
Output is correct |
6 |
Correct |
26 ms |
23800 KB |
Output is correct |
7 |
Correct |
27 ms |
23928 KB |
Output is correct |
8 |
Correct |
28 ms |
23928 KB |
Output is correct |
9 |
Correct |
27 ms |
23928 KB |
Output is correct |
10 |
Correct |
65 ms |
24668 KB |
Output is correct |
11 |
Correct |
101 ms |
25140 KB |
Output is correct |
12 |
Correct |
131 ms |
25748 KB |
Output is correct |
13 |
Correct |
142 ms |
25888 KB |
Output is correct |
14 |
Correct |
242 ms |
25340 KB |
Output is correct |
15 |
Correct |
82 ms |
24824 KB |
Output is correct |
16 |
Correct |
83 ms |
24952 KB |
Output is correct |
17 |
Correct |
1093 ms |
25312 KB |
Output is correct |
18 |
Correct |
24 ms |
23800 KB |
Output is correct |
19 |
Correct |
24 ms |
23800 KB |
Output is correct |
20 |
Correct |
24 ms |
23800 KB |
Output is correct |
21 |
Correct |
25 ms |
23800 KB |
Output is correct |
22 |
Correct |
25 ms |
23800 KB |
Output is correct |
23 |
Correct |
30 ms |
23928 KB |
Output is correct |
24 |
Correct |
33 ms |
23928 KB |
Output is correct |
25 |
Correct |
39 ms |
24056 KB |
Output is correct |
26 |
Correct |
38 ms |
23928 KB |
Output is correct |
27 |
Correct |
634 ms |
24768 KB |
Output is correct |
28 |
Correct |
1523 ms |
25720 KB |
Output is correct |
29 |
Correct |
1683 ms |
25976 KB |
Output is correct |
30 |
Correct |
1341 ms |
25504 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1851 ms |
25080 KB |
Output is correct |
2 |
Correct |
24 ms |
23800 KB |
Output is correct |
3 |
Correct |
26 ms |
23800 KB |
Output is correct |
4 |
Correct |
24 ms |
23800 KB |
Output is correct |
5 |
Correct |
27 ms |
24056 KB |
Output is correct |
6 |
Correct |
27 ms |
23928 KB |
Output is correct |
7 |
Correct |
28 ms |
23932 KB |
Output is correct |
8 |
Correct |
1927 ms |
25080 KB |
Output is correct |
9 |
Correct |
1749 ms |
25080 KB |
Output is correct |
10 |
Correct |
240 ms |
24440 KB |
Output is correct |
11 |
Correct |
67 ms |
25464 KB |
Output is correct |
12 |
Correct |
24 ms |
23800 KB |
Output is correct |
13 |
Correct |
57 ms |
23868 KB |
Output is correct |
14 |
Correct |
25 ms |
23928 KB |
Output is correct |
15 |
Correct |
25 ms |
23928 KB |
Output is correct |
16 |
Correct |
25 ms |
23800 KB |
Output is correct |
17 |
Correct |
28 ms |
24228 KB |
Output is correct |
18 |
Correct |
30 ms |
24240 KB |
Output is correct |
19 |
Correct |
49 ms |
25720 KB |
Output is correct |
20 |
Correct |
85 ms |
28280 KB |
Output is correct |
21 |
Correct |
70 ms |
27280 KB |
Output is correct |
22 |
Correct |
60 ms |
26488 KB |
Output is correct |
23 |
Correct |
87 ms |
28268 KB |
Output is correct |
24 |
Correct |
61 ms |
26616 KB |
Output is correct |
25 |
Correct |
57 ms |
26232 KB |
Output is correct |
26 |
Correct |
56 ms |
26176 KB |
Output is correct |
27 |
Correct |
24 ms |
23800 KB |
Output is correct |
28 |
Correct |
24 ms |
23800 KB |
Output is correct |
29 |
Correct |
25 ms |
23928 KB |
Output is correct |
30 |
Correct |
25 ms |
23800 KB |
Output is correct |
31 |
Correct |
25 ms |
23800 KB |
Output is correct |
32 |
Correct |
26 ms |
23800 KB |
Output is correct |
33 |
Correct |
27 ms |
23928 KB |
Output is correct |
34 |
Correct |
28 ms |
23928 KB |
Output is correct |
35 |
Correct |
27 ms |
23928 KB |
Output is correct |
36 |
Correct |
65 ms |
24668 KB |
Output is correct |
37 |
Correct |
101 ms |
25140 KB |
Output is correct |
38 |
Correct |
131 ms |
25748 KB |
Output is correct |
39 |
Correct |
142 ms |
25888 KB |
Output is correct |
40 |
Correct |
242 ms |
25340 KB |
Output is correct |
41 |
Correct |
82 ms |
24824 KB |
Output is correct |
42 |
Correct |
83 ms |
24952 KB |
Output is correct |
43 |
Correct |
1093 ms |
25312 KB |
Output is correct |
44 |
Correct |
24 ms |
23800 KB |
Output is correct |
45 |
Correct |
24 ms |
23800 KB |
Output is correct |
46 |
Correct |
24 ms |
23800 KB |
Output is correct |
47 |
Correct |
25 ms |
23800 KB |
Output is correct |
48 |
Correct |
25 ms |
23800 KB |
Output is correct |
49 |
Correct |
30 ms |
23928 KB |
Output is correct |
50 |
Correct |
33 ms |
23928 KB |
Output is correct |
51 |
Correct |
39 ms |
24056 KB |
Output is correct |
52 |
Correct |
38 ms |
23928 KB |
Output is correct |
53 |
Correct |
634 ms |
24768 KB |
Output is correct |
54 |
Correct |
1523 ms |
25720 KB |
Output is correct |
55 |
Correct |
1683 ms |
25976 KB |
Output is correct |
56 |
Correct |
1341 ms |
25504 KB |
Output is correct |
57 |
Execution timed out |
3047 ms |
30044 KB |
Time limit exceeded |
58 |
Halted |
0 ms |
0 KB |
- |