답안 #245178

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
245178 2020-07-05T16:28:38 Z Tc14 Toll (BOI17_toll) C++17
10 / 100
96 ms 6240 KB
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define ve vector
typedef long long ll;

const int INF = 1e9;

int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int k, n, m, o, a, b, t, u, v, d, dNew;
    ve<ve<pair<int, int>>> G;
    ve<int> D;
    priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>>> PQ;

    cin >> k >> n >> m >> o;
    G = ve<ve<pair<int, int>>>(n);
    D = vector<int>(n, INF);

    for (int i = 0; i < m; i++) {
        cin >> a >> b >> t;
        G[a].push_back({b, t});
    }

    D[0] = 0;
    PQ.push({0, 0});

    while (!PQ.empty()) {
        tie(d, u) = PQ.top();
        PQ.pop();
        for (pair<int, int> e : G[u]) {
            tie(v, t) = e;
            dNew = d + t;
            if (dNew < D[v]) {
                D[v] = dNew;
                PQ.push({dNew, v});
            }
        }
    }

    for (int i = 0; i < o; i++) {
        cin >> a >> b;
        if (D[b] == INF) cout << -1 << endl;
        else cout << D[b] << endl;
    }

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 4344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 4984 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 29 ms 512 KB Output is correct
8 Correct 27 ms 512 KB Output is correct
9 Correct 49 ms 4224 KB Output is correct
10 Correct 96 ms 6240 KB Output is correct
11 Correct 83 ms 5104 KB Output is correct
12 Correct 59 ms 4472 KB Output is correct
13 Correct 92 ms 5988 KB Output is correct
14 Correct 50 ms 4216 KB Output is correct
15 Correct 51 ms 3712 KB Output is correct
16 Correct 48 ms 3704 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 5 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 53 ms 4344 KB Output isn't correct
2 Halted 0 ms 0 KB -