답안 #879722

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
879722 2023-11-28T02:16:36 Z Alora Autobus (COCI22_autobus) C++17
70 / 70
97 ms 3928 KB
#include <bits/stdc++.h>
#define Alora "cownav"
#define fi(i,a,b) for(int i = a; i <= b; i++)
#define fid(i,a,b) for(int i = a; i >= b; i--)
#define ll long long
#define f first
#define se second
#define pii pair<int, int>
#define getbit(i, j) ((i >> j) & 1)
#define all(v) v.begin(), v.end()
#define pb push_back
#define maxn 75
const int M = 1e9 + 7;
using namespace std;
int n, m, k, q;
ll dp[maxn][maxn][maxn];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	if(fopen(Alora".inp", "r")){
    freopen(Alora".inp", "r", stdin);
    freopen(Alora".out", "w", stdout);}
    cin >> n >> m;
    memset(dp, 60, sizeof(dp));
    fi(i, 1, n) dp[0][i][i] = 0;
    fi(i, 1, m){
        int a, b, c;
        cin >> a >> b >> c;
        dp[1][a][b] = min(dp[1][a][b], 1ll*c);
    }
    cin >> k >> q;
    k = min(k, n - 1);
    fi(d, 0, k - 1)
        fi(t, 1, n)
            fi(u, 1, n)
                fi(v, 1, n)
                    dp[d + 1][u][v] = min(dp[d + 1][u][v], dp[d][u][t] + dp[1][t][v]);

    while(q--){
        int u, v; cin >> u >> v;
        ll ans = 1e18;
        fi(d, 0, k) ans = min(ans, dp[d][u][v]);
        if(ans != 1e18) cout << ans << '\n';
        else cout << -1 << '\n';
    }
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:21:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |     freopen(Alora".inp", "r", stdin);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
Main.cpp:22:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   22 |     freopen(Alora".out", "w", stdout);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3676 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 3676 KB Output is correct
2 Correct 2 ms 3676 KB Output is correct
3 Correct 3 ms 3676 KB Output is correct
4 Correct 3 ms 3676 KB Output is correct
5 Correct 3 ms 3676 KB Output is correct
6 Correct 3 ms 3676 KB Output is correct
7 Correct 4 ms 3928 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3676 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
7 Correct 8 ms 3676 KB Output is correct
8 Correct 23 ms 3760 KB Output is correct
9 Correct 3 ms 3676 KB Output is correct
10 Correct 12 ms 3676 KB Output is correct
11 Correct 5 ms 3676 KB Output is correct
12 Correct 15 ms 3676 KB Output is correct
13 Correct 71 ms 3736 KB Output is correct
14 Correct 71 ms 3672 KB Output is correct
15 Correct 84 ms 3672 KB Output is correct
16 Correct 74 ms 3676 KB Output is correct
17 Correct 78 ms 3736 KB Output is correct
18 Correct 70 ms 3672 KB Output is correct
19 Correct 97 ms 3740 KB Output is correct
20 Correct 93 ms 3676 KB Output is correct
21 Correct 71 ms 3752 KB Output is correct
22 Correct 74 ms 3924 KB Output is correct
23 Correct 73 ms 3752 KB Output is correct
24 Correct 80 ms 3736 KB Output is correct
25 Correct 78 ms 3672 KB Output is correct
26 Correct 82 ms 3672 KB Output is correct
27 Correct 79 ms 3676 KB Output is correct
28 Correct 77 ms 3740 KB Output is correct
29 Correct 70 ms 3752 KB Output is correct
30 Correct 77 ms 3736 KB Output is correct
31 Correct 96 ms 3736 KB Output is correct
32 Correct 88 ms 3676 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 3676 KB Output is correct
2 Correct 1 ms 3676 KB Output is correct
3 Correct 1 ms 3676 KB Output is correct
4 Correct 1 ms 3676 KB Output is correct
5 Correct 1 ms 3676 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
7 Correct 2 ms 3676 KB Output is correct
8 Correct 2 ms 3676 KB Output is correct
9 Correct 3 ms 3676 KB Output is correct
10 Correct 3 ms 3676 KB Output is correct
11 Correct 3 ms 3676 KB Output is correct
12 Correct 3 ms 3676 KB Output is correct
13 Correct 4 ms 3928 KB Output is correct
14 Correct 8 ms 3676 KB Output is correct
15 Correct 23 ms 3760 KB Output is correct
16 Correct 3 ms 3676 KB Output is correct
17 Correct 12 ms 3676 KB Output is correct
18 Correct 5 ms 3676 KB Output is correct
19 Correct 15 ms 3676 KB Output is correct
20 Correct 71 ms 3736 KB Output is correct
21 Correct 71 ms 3672 KB Output is correct
22 Correct 84 ms 3672 KB Output is correct
23 Correct 74 ms 3676 KB Output is correct
24 Correct 78 ms 3736 KB Output is correct
25 Correct 70 ms 3672 KB Output is correct
26 Correct 97 ms 3740 KB Output is correct
27 Correct 93 ms 3676 KB Output is correct
28 Correct 71 ms 3752 KB Output is correct
29 Correct 74 ms 3924 KB Output is correct
30 Correct 73 ms 3752 KB Output is correct
31 Correct 80 ms 3736 KB Output is correct
32 Correct 78 ms 3672 KB Output is correct
33 Correct 82 ms 3672 KB Output is correct
34 Correct 79 ms 3676 KB Output is correct
35 Correct 77 ms 3740 KB Output is correct
36 Correct 70 ms 3752 KB Output is correct
37 Correct 77 ms 3736 KB Output is correct
38 Correct 96 ms 3736 KB Output is correct
39 Correct 88 ms 3676 KB Output is correct
40 Correct 7 ms 3676 KB Output is correct
41 Correct 20 ms 3760 KB Output is correct
42 Correct 4 ms 3676 KB Output is correct
43 Correct 21 ms 3676 KB Output is correct
44 Correct 5 ms 3676 KB Output is correct
45 Correct 22 ms 3756 KB Output is correct
46 Correct 71 ms 3740 KB Output is correct
47 Correct 79 ms 3672 KB Output is correct
48 Correct 76 ms 3672 KB Output is correct
49 Correct 87 ms 3672 KB Output is correct
50 Correct 71 ms 3676 KB Output is correct
51 Correct 75 ms 3740 KB Output is correct
52 Correct 73 ms 3924 KB Output is correct
53 Correct 90 ms 3672 KB Output is correct
54 Correct 83 ms 3736 KB Output is correct
55 Correct 75 ms 3736 KB Output is correct
56 Correct 87 ms 3748 KB Output is correct
57 Correct 88 ms 3672 KB Output is correct
58 Correct 72 ms 3928 KB Output is correct
59 Correct 79 ms 3672 KB Output is correct
60 Correct 86 ms 3676 KB Output is correct
61 Correct 96 ms 3924 KB Output is correct
62 Correct 70 ms 3672 KB Output is correct
63 Correct 74 ms 3732 KB Output is correct
64 Correct 75 ms 3676 KB Output is correct
65 Correct 90 ms 3736 KB Output is correct