結果

問題 No.2674 k-Walk on Bipartite
ユーザー Tatsu_mrTatsu_mr
提出日時 2024-03-15 22:00:13
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,383 bytes
コンパイル時間 2,520 ms
コンパイル使用メモリ 215,056 KB
実行使用メモリ 19,296 KB
最終ジャッジ日時 2024-03-15 22:00:37
合計ジャッジ時間 6,684 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 139 ms
14,348 KB
testcase_08 AC 195 ms
14,976 KB
testcase_09 AC 106 ms
14,000 KB
testcase_10 AC 245 ms
17,280 KB
testcase_11 AC 144 ms
13,184 KB
testcase_12 AC 241 ms
17,376 KB
testcase_13 AC 92 ms
12,820 KB
testcase_14 AC 24 ms
8,960 KB
testcase_15 AC 254 ms
18,308 KB
testcase_16 AC 178 ms
15,624 KB
testcase_17 AC 179 ms
14,464 KB
testcase_18 WA -
testcase_19 AC 121 ms
14,156 KB
testcase_20 AC 101 ms
13,756 KB
testcase_21 AC 195 ms
15,360 KB
testcase_22 AC 268 ms
19,296 KB
testcase_23 AC 2 ms
6,676 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 2 ms
6,676 KB
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 2 ms
6,676 KB
testcase_32 AC 2 ms
6,676 KB
testcase_33 AC 2 ms
6,676 KB
testcase_34 AC 2 ms
6,676 KB
testcase_35 AC 2 ms
6,676 KB
testcase_36 AC 2 ms
6,676 KB
testcase_37 AC 2 ms
6,676 KB
testcase_38 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int n, m, s, t, k;

vector<long long> dijkstra(vector<vector<pair<int, long long>>> &g, int x) {
    vector<long long> dist(n, 1000000000000000000);
    vector<bool> visit(n, false);
    priority_queue<pair<long long, int>, vector<pair<long long, int>>, greater<pair<long long, int>>> que;
    dist[x] = 0LL;
    que.push({dist[x], x});
    while (!que.empty()) {
        int v = que.top().second;
        que.pop();
        if (visit[v]) {
            continue;
        }
        visit[v] = true;
        for (auto p : g[v]) {
            int next_v = p.first;
            long long d = p.second;
            if (dist[next_v] > dist[v] + d) {
                dist[next_v] = dist[v] + d;
                que.push({dist[next_v], next_v});
            }
        }
    }
    return dist;
}

int main() {
    cin >> n >> m >> s >> t >> k;
    s--;
    t--;
    vector<vector<pair<int, long long>>> g(n);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back({b, 1LL});
        g[b].push_back({a, 1LL});
    }
    vector<long long> dist = dijkstra(g, s);
    if (abs(dist[t] - k) % 2 == 0) {
        if (dist[t] <= k) {
            cout << "Yes" << endl;
        } else {
            cout << "Unknown" << endl;
        }
    } else {
        cout << "No" << endl;
    }
}
0