# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
793500 |
2023-07-25T23:03:38 Z |
asdfgrace |
Toll (BOI17_toll) |
C++17 |
|
3000 ms |
4508 KB |
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
using namespace std;
constexpr int INF = 1000000007; //998244353;
int main() {
ios::sync_with_stdio(0); cin.tie(0);
int k, n, m, q;
cin >> k >> n >> m >> q;
vector<vector<pair<int, int>>> edges(n);
for (int i = 0; i < m; ++i) {
int a, b, w;
cin >> a >> b >> w;
edges[a].push_back({b, w});
}
vector<int> best(n, INF);
while (q--) {
int a, b;
cin >> a >> b;
fill(best.begin() + a, best.begin() + b + 1, INF);
best[a] = 0;
for (int i = a; i < b; ++i) {
for (auto [next, wt] : edges[i]) {
best[next] = min(best[next], best[i] + wt);
}
}
if (best[b] == INF) cout << -1 << '\n';
else cout << best[b] << '\n';
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
583 ms |
3400 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
461 ms |
3276 KB |
Output is correct |
9 |
Correct |
544 ms |
3208 KB |
Output is correct |
10 |
Correct |
129 ms |
1708 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2005 ms |
3400 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
0 ms |
212 KB |
Output is correct |
7 |
Correct |
10 ms |
392 KB |
Output is correct |
8 |
Correct |
17 ms |
440 KB |
Output is correct |
9 |
Correct |
762 ms |
3388 KB |
Output is correct |
10 |
Execution timed out |
3069 ms |
4288 KB |
Time limit exceeded |
11 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
17 ms |
3156 KB |
Output is correct |
11 |
Correct |
38 ms |
3236 KB |
Output is correct |
12 |
Correct |
62 ms |
4124 KB |
Output is correct |
13 |
Correct |
59 ms |
4428 KB |
Output is correct |
14 |
Correct |
54 ms |
3736 KB |
Output is correct |
15 |
Correct |
37 ms |
2388 KB |
Output is correct |
16 |
Correct |
33 ms |
2316 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
0 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
1 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
17 ms |
3156 KB |
Output is correct |
11 |
Correct |
38 ms |
3236 KB |
Output is correct |
12 |
Correct |
62 ms |
4124 KB |
Output is correct |
13 |
Correct |
59 ms |
4428 KB |
Output is correct |
14 |
Correct |
54 ms |
3736 KB |
Output is correct |
15 |
Correct |
37 ms |
2388 KB |
Output is correct |
16 |
Correct |
33 ms |
2316 KB |
Output is correct |
17 |
Correct |
488 ms |
3272 KB |
Output is correct |
18 |
Correct |
0 ms |
212 KB |
Output is correct |
19 |
Correct |
0 ms |
212 KB |
Output is correct |
20 |
Correct |
0 ms |
212 KB |
Output is correct |
21 |
Correct |
1 ms |
212 KB |
Output is correct |
22 |
Correct |
0 ms |
212 KB |
Output is correct |
23 |
Correct |
3 ms |
340 KB |
Output is correct |
24 |
Correct |
4 ms |
340 KB |
Output is correct |
25 |
Correct |
9 ms |
340 KB |
Output is correct |
26 |
Correct |
7 ms |
424 KB |
Output is correct |
27 |
Correct |
186 ms |
3252 KB |
Output is correct |
28 |
Correct |
862 ms |
4176 KB |
Output is correct |
29 |
Correct |
776 ms |
4508 KB |
Output is correct |
30 |
Correct |
697 ms |
3772 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
583 ms |
3400 KB |
Output is correct |
2 |
Correct |
0 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
461 ms |
3276 KB |
Output is correct |
9 |
Correct |
544 ms |
3208 KB |
Output is correct |
10 |
Correct |
129 ms |
1708 KB |
Output is correct |
11 |
Correct |
2005 ms |
3400 KB |
Output is correct |
12 |
Correct |
0 ms |
212 KB |
Output is correct |
13 |
Correct |
1 ms |
212 KB |
Output is correct |
14 |
Correct |
0 ms |
212 KB |
Output is correct |
15 |
Correct |
0 ms |
212 KB |
Output is correct |
16 |
Correct |
0 ms |
212 KB |
Output is correct |
17 |
Correct |
10 ms |
392 KB |
Output is correct |
18 |
Correct |
17 ms |
440 KB |
Output is correct |
19 |
Correct |
762 ms |
3388 KB |
Output is correct |
20 |
Execution timed out |
3069 ms |
4288 KB |
Time limit exceeded |
21 |
Halted |
0 ms |
0 KB |
- |