結果

問題 No.2431 Viral Hotel
ユーザー polylogKpolylogK
提出日時 2023-09-28 18:14:41
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,729 bytes
コンパイル時間 2,264 ms
コンパイル使用メモリ 208,640 KB
実行使用メモリ 10,348 KB
最終ジャッジ日時 2023-09-28 18:14:49
合計ジャッジ時間 8,224 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 18 ms
4,508 KB
testcase_08 AC 18 ms
4,500 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 4 ms
4,376 KB
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 AC 2 ms
4,380 KB
testcase_40 AC 2 ms
4,376 KB
testcase_41 AC 2 ms
4,376 KB
testcase_42 AC 2 ms
4,376 KB
testcase_43 WA -
testcase_44 WA -
testcase_45 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = std::int_fast64_t;
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

#if defined(DONLINE_JUDGE)
#define NDEBUG
#elif defined(ONLINE_JUDGE)
#define NDEBUG
#endif

template <typename T>
std::vector<T> make_v(size_t a) {
    return std::vector<T>(a);
}
template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return std::vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

int main() {
    int n, k, m, p;
    scanf("%d%d%d%d", &n, &k, &m, &p);
    std::vector<std::vector<int>> g(n);
    for (int i = 0; i < m; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a;
        --b;

        g[a].push_back(b);
        g[b].push_back(a);
    }
    std::vector<int> s(n);
    for (auto& v : s) scanf("%d", &v);

    using P = std::pair<int, int>;  // (time, vertex)
    std::priority_queue<P, std::vector<P>, std::greater<P>> qu;

    std::vector<int> imm(n, -1);
    for (int i = 0; i < k; ++i) {
        int x;
        scanf("%d", &x);
        --x;

        imm[x] = p;
        qu.push({s[x], x});
    }

    int ans = 0;
    while (!qu.empty()) {
        const auto [now, v] = qu.top();
        qu.pop();
        if (imm[v] == 0) continue;

        for (int to : g[v]) {
            if (imm[to] == -1) {
                imm[to] = now + p;
            } else if (now < imm[to]) {
                imm[to] = 0;
                ++ans;
                continue;
            } else if (imm[to] <= now) {
                continue;
            } else {
                std::abort();
            }

            qu.push({now + s[to], to});
        }
    }

    printf("%d\n", ans);
    return 0;
}
0