結果

問題 No.1473 おでぶなおばけさん
ユーザー 👑 hitonanodehitonanode
提出日時 2021-04-04 18:25:27
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,355 bytes
コンパイル時間 1,015 ms
コンパイル使用メモリ 90,532 KB
実行使用メモリ 9,904 KB
最終ジャッジ日時 2023-08-27 19:20:26
合計ジャッジ時間 7,041 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 106 ms
9,776 KB
testcase_03 AC 79 ms
8,652 KB
testcase_04 AC 55 ms
6,788 KB
testcase_05 AC 22 ms
4,492 KB
testcase_06 AC 105 ms
8,952 KB
testcase_07 AC 97 ms
9,904 KB
testcase_08 AC 123 ms
9,832 KB
testcase_09 AC 96 ms
9,888 KB
testcase_10 AC 42 ms
5,676 KB
testcase_11 AC 43 ms
6,516 KB
testcase_12 AC 43 ms
5,908 KB
testcase_13 AC 27 ms
5,292 KB
testcase_14 AC 20 ms
4,380 KB
testcase_15 AC 37 ms
5,564 KB
testcase_16 AC 40 ms
5,376 KB
testcase_17 AC 4 ms
4,376 KB
testcase_18 AC 6 ms
4,376 KB
testcase_19 AC 53 ms
5,736 KB
testcase_20 AC 71 ms
8,180 KB
testcase_21 AC 93 ms
7,092 KB
testcase_22 AC 120 ms
8,884 KB
testcase_23 AC 100 ms
8,136 KB
testcase_24 AC 95 ms
7,796 KB
testcase_25 AC 121 ms
8,576 KB
testcase_26 AC 119 ms
8,584 KB
testcase_27 AC 31 ms
4,800 KB
testcase_28 AC 92 ms
9,716 KB
testcase_29 AC 64 ms
7,444 KB
testcase_30 AC 79 ms
7,980 KB
testcase_31 AC 86 ms
9,684 KB
testcase_32 AC 99 ms
9,088 KB
testcase_33 AC 59 ms
7,732 KB
testcase_34 AC 32 ms
5,688 KB
testcase_35 AC 34 ms
5,568 KB
testcase_36 AC 66 ms
6,516 KB
testcase_37 AC 94 ms
7,824 KB
testcase_38 AC 14 ms
4,380 KB
testcase_39 AC 41 ms
5,248 KB
testcase_40 AC 40 ms
5,328 KB
testcase_41 WA -
testcase_42 WA -
testcase_43 AC 45 ms
7,444 KB
testcase_44 AC 45 ms
7,492 KB
testcase_45 AC 46 ms
7,556 KB
testcase_46 AC 54 ms
7,500 KB
testcase_47 AC 67 ms
8,492 KB
testcase_48 AC 67 ms
8,092 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

// 二分探索解だが WA になってほしい
#include <algorithm>
#include <iostream>
#include <queue>
#include <vector>
using namespace std;

int main() {
    cin.tie(nullptr), ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;
    vector<vector<pair<int, int>>> to(N);
    vector<int> ds;
    for (int e = 0; e < M; e++) {
        int s, t, d;
        cin >> s >> t >> d;
        s--, t--;
        to[s].emplace_back(t, d);
        to[t].emplace_back(s, d);
        ds.push_back(d);
    }

    sort(ds.begin(), ds.end());
    // ds.erase(unique(ds.begin(), ds.end()), ds.end());
    int ok = 0, ng = ds.size() - 1; // 間違える WAになってほしい

    auto solve = [&](int th) -> int {
        vector<int> dist(N, 1 << 30);
        dist[0] = 0;
        queue<int> q;
        q.push(0);
        while (!q.empty()) {
            int now = q.front();
            q.pop();
            for (auto [nxt, w] : to[now]) {
                if (w >= th and dist[nxt] > dist[now] + 1) {
                    dist[nxt] = dist[now] + 1;
                    q.push(nxt);
                }
            }
        }
        return dist.back();
    };

    while (ng - ok > 1) {
        const int c = (ok + ng) / 2;
        auto ret = solve(ds[c]);
        (ret == 1 << 30 ? ng : ok) = c;
    }
    cout << ds[ok] << ' ' << solve(ds[ok]) << '\n';
}
0