Submission #1053479

# Submission time Handle Problem Language Result Execution time Memory
1053479 2024-08-11T12:23:04 Z ArthuroWich Toll (BOI17_toll) C++17
0 / 100
5 ms 13148 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long int
int dp[500][500][5][5];
void solve() {
    int n, o, m, k;
    cin >> k >> n >> m >> o;
    for (int i = 0; i < 55; i++) {
        for (int j = 0; j < 55; j++) {
            for (int x = 0; x < 5; x++) {
                for (int y = 0; y < 5; y++) {
                    dp[i][j][x][y] = INT_MAX;
                }
            }
        }
    }
    for (int i = 0; i < m; i++) {
        int u, v, w;
        cin >> u >> v >> w;
        dp[u/k][v/k][u%k][v%k] = min(dp[u/k][v/k][u%k][v%k], w);
    }
    for (int c = 0; c < n; c++) {
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < n; j++) {
                dp[i/k][j/k][i%k][j%k] = min(dp[i/k][j/k][i%k][j%k], dp[i/k][c/k][i%k][c%k]+dp[c/k][j/k][c%k][j%k]);
            }
        }
    }
    while(o--) {
        int a, b;
        cin >> a >> b;
        cout << dp[a/k][b/k][a%k][b%k] << endl;
    }
}
int32_t main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    t = 1;
    while(t--) {
        solve();
    }
}
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 13148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 13148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 13148 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -