Submission #244707

# Submission time Handle Problem Language Result Execution time Memory
244707 2020-07-04T16:18:39 Z santaclaus03 Toll (BOI17_toll) C++14
10 / 100
209 ms 6392 KB
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;
using vvii = vector<vector<ii>>;

#define INF 1000000000

int main() {
    int K, n, m, o; cin >> K >> n >> m >> o;
    vvii rev(n);
    for (int i = 0; i < m; ++i) {
        int a, b, t; cin >> a >> b >> t;
        rev[b].emplace_back(t, a);
    }
    vi dist(n, INF);
    dist[0] = 0;
    for (int u = 1; u < n; ++u) {
        for (ii e : rev[u]) {
            dist[u] = min(dist[u], dist[e.second] + e.first);
        }
    }
    for (int i = 0; i < o; ++i) {
        int a, b; cin >> a >> b;
        assert(a == 0);
        int ans = dist[b];
        cout << (ans == INF ? -1 : ans) << endl;
    }
    return 0;
}
# Verdict Execution time Memory Grader output
1 Runtime error 74 ms 6392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 162 ms 3344 KB Output is correct
2 Correct 5 ms 256 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 5 ms 256 KB Output is correct
6 Correct 5 ms 256 KB Output is correct
7 Correct 31 ms 512 KB Output is correct
8 Correct 32 ms 512 KB Output is correct
9 Correct 99 ms 4148 KB Output is correct
10 Correct 209 ms 4740 KB Output is correct
11 Correct 170 ms 3936 KB Output is correct
12 Correct 135 ms 3808 KB Output is correct
13 Correct 202 ms 4432 KB Output is correct
14 Correct 130 ms 3424 KB Output is correct
15 Correct 115 ms 3064 KB Output is correct
16 Correct 115 ms 3052 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 74 ms 6392 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -