Submission #879721

# Submission time Handle Problem Language Result Execution time Memory
879721 2023-11-28T02:16:05 Z Alora Autobus (COCI22_autobus) C++17
70 / 70
97 ms 10268 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);
    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);}
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory 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 3536 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3676 KB Output is correct
2 Correct 2 ms 3760 KB Output is correct
3 Correct 3 ms 3672 KB Output is correct
4 Correct 3 ms 3676 KB Output is correct
5 Correct 3 ms 3676 KB Output is correct
6 Correct 4 ms 3676 KB Output is correct
7 Correct 3 ms 3676 KB Output is correct
# Verdict Execution time Memory 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 3536 KB Output is correct
6 Correct 1 ms 3676 KB Output is correct
7 Correct 8 ms 3676 KB Output is correct
8 Correct 21 ms 3792 KB Output is correct
9 Correct 3 ms 3676 KB Output is correct
10 Correct 12 ms 3676 KB Output is correct
11 Correct 6 ms 3676 KB Output is correct
12 Correct 14 ms 3672 KB Output is correct
13 Correct 72 ms 9872 KB Output is correct
14 Correct 73 ms 9756 KB Output is correct
15 Correct 86 ms 9812 KB Output is correct
16 Correct 77 ms 9812 KB Output is correct
17 Correct 73 ms 9808 KB Output is correct
18 Correct 73 ms 9752 KB Output is correct
19 Correct 95 ms 9820 KB Output is correct
20 Correct 84 ms 9752 KB Output is correct
21 Correct 73 ms 9808 KB Output is correct
22 Correct 76 ms 9884 KB Output is correct
23 Correct 75 ms 10016 KB Output is correct
24 Correct 83 ms 9808 KB Output is correct
25 Correct 75 ms 9876 KB Output is correct
26 Correct 94 ms 10064 KB Output is correct
27 Correct 80 ms 10000 KB Output is correct
28 Correct 82 ms 10244 KB Output is correct
29 Correct 92 ms 9744 KB Output is correct
30 Correct 75 ms 9808 KB Output is correct
31 Correct 87 ms 9808 KB Output is correct
32 Correct 90 ms 9752 KB Output is correct
# Verdict Execution time Memory 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 3536 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 3760 KB Output is correct
9 Correct 3 ms 3672 KB Output is correct
10 Correct 3 ms 3676 KB Output is correct
11 Correct 3 ms 3676 KB Output is correct
12 Correct 4 ms 3676 KB Output is correct
13 Correct 3 ms 3676 KB Output is correct
14 Correct 8 ms 3676 KB Output is correct
15 Correct 21 ms 3792 KB Output is correct
16 Correct 3 ms 3676 KB Output is correct
17 Correct 12 ms 3676 KB Output is correct
18 Correct 6 ms 3676 KB Output is correct
19 Correct 14 ms 3672 KB Output is correct
20 Correct 72 ms 9872 KB Output is correct
21 Correct 73 ms 9756 KB Output is correct
22 Correct 86 ms 9812 KB Output is correct
23 Correct 77 ms 9812 KB Output is correct
24 Correct 73 ms 9808 KB Output is correct
25 Correct 73 ms 9752 KB Output is correct
26 Correct 95 ms 9820 KB Output is correct
27 Correct 84 ms 9752 KB Output is correct
28 Correct 73 ms 9808 KB Output is correct
29 Correct 76 ms 9884 KB Output is correct
30 Correct 75 ms 10016 KB Output is correct
31 Correct 83 ms 9808 KB Output is correct
32 Correct 75 ms 9876 KB Output is correct
33 Correct 94 ms 10064 KB Output is correct
34 Correct 80 ms 10000 KB Output is correct
35 Correct 82 ms 10244 KB Output is correct
36 Correct 92 ms 9744 KB Output is correct
37 Correct 75 ms 9808 KB Output is correct
38 Correct 87 ms 9808 KB Output is correct
39 Correct 90 ms 9752 KB Output is correct
40 Correct 7 ms 3776 KB Output is correct
41 Correct 21 ms 3676 KB Output is correct
42 Correct 5 ms 3928 KB Output is correct
43 Correct 21 ms 3780 KB Output is correct
44 Correct 5 ms 3796 KB Output is correct
45 Correct 22 ms 3676 KB Output is correct
46 Correct 72 ms 9876 KB Output is correct
47 Correct 93 ms 9760 KB Output is correct
48 Correct 75 ms 9808 KB Output is correct
49 Correct 97 ms 10268 KB Output is correct
50 Correct 73 ms 9748 KB Output is correct
51 Correct 80 ms 9808 KB Output is correct
52 Correct 72 ms 9940 KB Output is correct
53 Correct 95 ms 9816 KB Output is correct
54 Correct 74 ms 9868 KB Output is correct
55 Correct 74 ms 10008 KB Output is correct
56 Correct 90 ms 9808 KB Output is correct
57 Correct 91 ms 9872 KB Output is correct
58 Correct 81 ms 10072 KB Output is correct
59 Correct 82 ms 9888 KB Output is correct
60 Correct 89 ms 10000 KB Output is correct
61 Correct 93 ms 10064 KB Output is correct
62 Correct 72 ms 9808 KB Output is correct
63 Correct 77 ms 9808 KB Output is correct
64 Correct 77 ms 9628 KB Output is correct
65 Correct 90 ms 9812 KB Output is correct