답안 #793501

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
793501 2023-07-25T23:04:26 Z asdfgrace Toll (BOI17_toll) C++17
100 / 100
2213 ms 4480 KB
#include <bits/stdc++.h>
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';
  }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 682 ms 3276 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 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 666 ms 3276 KB Output is correct
9 Correct 668 ms 3204 KB Output is correct
10 Correct 201 ms 1740 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1432 ms 3304 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 1 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 20 ms 408 KB Output is correct
8 Correct 21 ms 456 KB Output is correct
9 Correct 1018 ms 3376 KB Output is correct
10 Correct 2213 ms 4480 KB Output is correct
11 Correct 1519 ms 3312 KB Output is correct
12 Correct 1720 ms 3168 KB Output is correct
13 Correct 542 ms 3892 KB Output is correct
14 Correct 374 ms 2940 KB Output is correct
15 Correct 436 ms 2452 KB Output is correct
16 Correct 408 ms 2456 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 1 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 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 18 ms 3156 KB Output is correct
11 Correct 32 ms 3260 KB Output is correct
12 Correct 43 ms 4160 KB Output is correct
13 Correct 46 ms 4304 KB Output is correct
14 Correct 38 ms 3764 KB Output is correct
15 Correct 25 ms 2432 KB Output is correct
16 Correct 24 ms 2388 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 1 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 2 ms 340 KB Output is correct
9 Correct 1 ms 340 KB Output is correct
10 Correct 18 ms 3156 KB Output is correct
11 Correct 32 ms 3260 KB Output is correct
12 Correct 43 ms 4160 KB Output is correct
13 Correct 46 ms 4304 KB Output is correct
14 Correct 38 ms 3764 KB Output is correct
15 Correct 25 ms 2432 KB Output is correct
16 Correct 24 ms 2388 KB Output is correct
17 Correct 309 ms 3268 KB Output is correct
18 Correct 1 ms 212 KB Output is correct
19 Correct 1 ms 212 KB Output is correct
20 Correct 0 ms 256 KB Output is correct
21 Correct 0 ms 212 KB Output is correct
22 Correct 1 ms 256 KB Output is correct
23 Correct 5 ms 340 KB Output is correct
24 Correct 5 ms 340 KB Output is correct
25 Correct 8 ms 436 KB Output is correct
26 Correct 7 ms 340 KB Output is correct
27 Correct 202 ms 3240 KB Output is correct
28 Correct 416 ms 4184 KB Output is correct
29 Correct 497 ms 4440 KB Output is correct
30 Correct 446 ms 3768 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 682 ms 3276 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 2 ms 340 KB Output is correct
6 Correct 2 ms 340 KB Output is correct
7 Correct 2 ms 340 KB Output is correct
8 Correct 666 ms 3276 KB Output is correct
9 Correct 668 ms 3204 KB Output is correct
10 Correct 201 ms 1740 KB Output is correct
11 Correct 1432 ms 3304 KB Output is correct
12 Correct 0 ms 212 KB Output is correct
13 Correct 0 ms 212 KB Output is correct
14 Correct 1 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 20 ms 408 KB Output is correct
18 Correct 21 ms 456 KB Output is correct
19 Correct 1018 ms 3376 KB Output is correct
20 Correct 2213 ms 4480 KB Output is correct
21 Correct 1519 ms 3312 KB Output is correct
22 Correct 1720 ms 3168 KB Output is correct
23 Correct 542 ms 3892 KB Output is correct
24 Correct 374 ms 2940 KB Output is correct
25 Correct 436 ms 2452 KB Output is correct
26 Correct 408 ms 2456 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 0 ms 212 KB Output is correct
29 Correct 0 ms 212 KB Output is correct
30 Correct 1 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 1 ms 340 KB Output is correct
33 Correct 1 ms 340 KB Output is correct
34 Correct 2 ms 340 KB Output is correct
35 Correct 1 ms 340 KB Output is correct
36 Correct 18 ms 3156 KB Output is correct
37 Correct 32 ms 3260 KB Output is correct
38 Correct 43 ms 4160 KB Output is correct
39 Correct 46 ms 4304 KB Output is correct
40 Correct 38 ms 3764 KB Output is correct
41 Correct 25 ms 2432 KB Output is correct
42 Correct 24 ms 2388 KB Output is correct
43 Correct 309 ms 3268 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 1 ms 212 KB Output is correct
46 Correct 0 ms 256 KB Output is correct
47 Correct 0 ms 212 KB Output is correct
48 Correct 1 ms 256 KB Output is correct
49 Correct 5 ms 340 KB Output is correct
50 Correct 5 ms 340 KB Output is correct
51 Correct 8 ms 436 KB Output is correct
52 Correct 7 ms 340 KB Output is correct
53 Correct 202 ms 3240 KB Output is correct
54 Correct 416 ms 4184 KB Output is correct
55 Correct 497 ms 4440 KB Output is correct
56 Correct 446 ms 3768 KB Output is correct
57 Correct 1635 ms 4432 KB Output is correct
58 Correct 692 ms 3280 KB Output is correct
59 Correct 1010 ms 3320 KB Output is correct