답안 #973299

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
973299 2024-05-01T17:44:14 Z Circling Autobus (COCI22_autobus) C++17
70 / 70
139 ms 9696 KB
/*The British Royal Family and a small cadre of English Fabian Socialists, in
conjunction with the Rockefellers and the Rothchilds, are engaged in a
conspiracy to greatly reduce the population of the human race in order to head
off a Malthusian catastrophe, a catastrophe that could easily be avoided by
simply building a massive amount of nuclear power plants and a number of massive
superhighways and bridges to connect all of the world's continents. But doing
that would cut into the conspiracy's profits. So the British Royal Family
invented environmentalism and neoliberalism in order to hide the truth. And in
order to further reduce the population, the British Royal Family is also the
world's foremost drug trafficking conspiracy. And it uses its control of the IMF
to push austerity in order to kill as many people in the global south as
possible.
And also Henry Kissinger is a gay KGB agent. */
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;


int64_t n, m, road[70][70], dp[70][70][70], a, b, t, k, q;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++){
        for (int j = 0; j < n; j++){
            road[i][j] = i == j ? 0 : 69000001;
            dp[i][j][0] = road[i][j];
        }
    }
    for (int i = 0; i < m; i++){
        cin >> a >> b >> t;
        a--;
        b--;
        road[a][b] = min(road[a][b], t);
    }
    for (k = 1; k < n; k++){
        for (int i = 0; i < n; i++){
            for (int j = 0; j < n; j++){
                dp[i][j][k] = dp[i][j][k - 1];
                for (int l = 0; l < n; l++) dp[i][j][k] = min(dp[i][j][k], dp[i][l][k - 1] + road[l][j]);
            }
        }
    }
    cin >> k >> q;
    k = min(k, n - 1);
    while (q--){
        cin >> a >> b;
        a--;
        b--;
        cout << (dp[a][b][k] < 69000001 ? dp[a][b][k] : -1) << '\n';
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 3160 KB Output is correct
2 Correct 25 ms 3456 KB Output is correct
3 Correct 28 ms 3188 KB Output is correct
4 Correct 26 ms 3416 KB Output is correct
5 Correct 25 ms 3160 KB Output is correct
6 Correct 26 ms 3164 KB Output is correct
7 Correct 26 ms 3164 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 27 ms 3192 KB Output is correct
8 Correct 25 ms 3416 KB Output is correct
9 Correct 28 ms 3164 KB Output is correct
10 Correct 28 ms 3160 KB Output is correct
11 Correct 29 ms 3264 KB Output is correct
12 Correct 27 ms 3204 KB Output is correct
13 Correct 130 ms 9312 KB Output is correct
14 Correct 97 ms 9296 KB Output is correct
15 Correct 139 ms 9548 KB Output is correct
16 Correct 120 ms 9172 KB Output is correct
17 Correct 95 ms 9296 KB Output is correct
18 Correct 97 ms 9384 KB Output is correct
19 Correct 96 ms 9300 KB Output is correct
20 Correct 112 ms 9180 KB Output is correct
21 Correct 106 ms 9432 KB Output is correct
22 Correct 99 ms 9296 KB Output is correct
23 Correct 98 ms 9412 KB Output is correct
24 Correct 96 ms 9424 KB Output is correct
25 Correct 105 ms 9424 KB Output is correct
26 Correct 99 ms 9516 KB Output is correct
27 Correct 99 ms 9300 KB Output is correct
28 Correct 100 ms 9520 KB Output is correct
29 Correct 95 ms 9172 KB Output is correct
30 Correct 98 ms 9176 KB Output is correct
31 Correct 94 ms 9180 KB Output is correct
32 Correct 99 ms 9292 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 4 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2392 KB Output is correct
7 Correct 25 ms 3160 KB Output is correct
8 Correct 25 ms 3456 KB Output is correct
9 Correct 28 ms 3188 KB Output is correct
10 Correct 26 ms 3416 KB Output is correct
11 Correct 25 ms 3160 KB Output is correct
12 Correct 26 ms 3164 KB Output is correct
13 Correct 26 ms 3164 KB Output is correct
14 Correct 27 ms 3192 KB Output is correct
15 Correct 25 ms 3416 KB Output is correct
16 Correct 28 ms 3164 KB Output is correct
17 Correct 28 ms 3160 KB Output is correct
18 Correct 29 ms 3264 KB Output is correct
19 Correct 27 ms 3204 KB Output is correct
20 Correct 130 ms 9312 KB Output is correct
21 Correct 97 ms 9296 KB Output is correct
22 Correct 139 ms 9548 KB Output is correct
23 Correct 120 ms 9172 KB Output is correct
24 Correct 95 ms 9296 KB Output is correct
25 Correct 97 ms 9384 KB Output is correct
26 Correct 96 ms 9300 KB Output is correct
27 Correct 112 ms 9180 KB Output is correct
28 Correct 106 ms 9432 KB Output is correct
29 Correct 99 ms 9296 KB Output is correct
30 Correct 98 ms 9412 KB Output is correct
31 Correct 96 ms 9424 KB Output is correct
32 Correct 105 ms 9424 KB Output is correct
33 Correct 99 ms 9516 KB Output is correct
34 Correct 99 ms 9300 KB Output is correct
35 Correct 100 ms 9520 KB Output is correct
36 Correct 95 ms 9172 KB Output is correct
37 Correct 98 ms 9176 KB Output is correct
38 Correct 94 ms 9180 KB Output is correct
39 Correct 99 ms 9292 KB Output is correct
40 Correct 25 ms 3164 KB Output is correct
41 Correct 25 ms 3164 KB Output is correct
42 Correct 25 ms 3224 KB Output is correct
43 Correct 25 ms 3228 KB Output is correct
44 Correct 25 ms 3164 KB Output is correct
45 Correct 30 ms 3164 KB Output is correct
46 Correct 105 ms 9696 KB Output is correct
47 Correct 98 ms 9308 KB Output is correct
48 Correct 93 ms 9296 KB Output is correct
49 Correct 117 ms 9312 KB Output is correct
50 Correct 104 ms 9172 KB Output is correct
51 Correct 98 ms 9300 KB Output is correct
52 Correct 96 ms 9296 KB Output is correct
53 Correct 97 ms 9296 KB Output is correct
54 Correct 102 ms 9436 KB Output is correct
55 Correct 96 ms 9296 KB Output is correct
56 Correct 108 ms 9420 KB Output is correct
57 Correct 99 ms 9412 KB Output is correct
58 Correct 99 ms 9304 KB Output is correct
59 Correct 105 ms 9428 KB Output is correct
60 Correct 97 ms 9428 KB Output is correct
61 Correct 97 ms 9296 KB Output is correct
62 Correct 94 ms 9044 KB Output is correct
63 Correct 97 ms 9292 KB Output is correct
64 Correct 93 ms 9172 KB Output is correct
65 Correct 94 ms 9180 KB Output is correct