結果
| 問題 | 
                            No.1473 おでぶなおばけさん
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2021-04-09 22:48:58 | 
| 言語 | C++14  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 2,284 bytes | 
| コンパイル時間 | 1,960 ms | 
| コンパイル使用メモリ | 189,960 KB | 
| 実行使用メモリ | 24,588 KB | 
| 最終ジャッジ日時 | 2024-06-25 06:29:42 | 
| 合計ジャッジ時間 | 5,797 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 1 WA * 1 | 
| other | TLE * 1 -- * 46 | 
ソースコード
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
const int INF = 1 << 30;
void Main() {
    int n, m;
    cin >> n >> m;
    vector<map<int, int>> graph(n, map<int, int>());
    for (int i = 0; i < m; ++i) {
        int s, t, d;
        cin >> s >> t >> d;
        --s;
        --t;
        if (graph[s].count(t) == 0) {
            graph[s].insert(make_pair(t, d));
            graph[t].insert(make_pair(s, d));
        }
        else {
            graph[s][t] = max(graph[s][t], d);
            graph[t][s] = max(graph[t][s], d);
        }
    }
    typedef pair<int, int> weight_curr;
    priority_queue<weight_curr, vector<weight_curr>, greater<weight_curr>> q;
    vector<int> w(n, -1);
    int start = 0;
    q.push(make_pair(INF, start));
    w[start] = INF;
    while (!q.empty()) {
        int weight = q.top().first;
        int curr = q.top().second;
        q.pop();
        if (w[curr] > weight) {
            continue;
        }
        for (auto edge : graph[curr]) {
            int to = edge.first;
            int wei = edge.second;
            if (w[to] < min(w[curr], wei)) {
                w[to] = min(w[curr], wei);
                q.push(make_pair(w[to], to));
            }
        }
    }
    int maxWeight = w[n - 1];
    cout << maxWeight << " 1" << endl;
    return;
    vector<set<int>> allowed(n, set<int>());
    for (int i = 0; i < n; ++i) {
        for (auto e : graph[i]) {
            if (e.second >= maxWeight) {
                allowed[i].insert(e.first);
            }
        }
    }
    typedef pair<int, int> dist_curr;
    priority_queue<dist_curr, vector<dist_curr>, greater<dist_curr>> aq;
    vector<int> d(n, INF);
    aq.push(make_pair(0, start));
    d[start] = 0;
    while (!aq.empty()) {
        int dist = aq.top().first;
        int curr = aq.top().second;
        aq.pop();
        if (d[curr] < dist) {
            continue;
        }
        for (auto to : allowed[curr]) {
            if (d[to] > d[curr] + 1) {
                d[to] = d[curr] + 1;
                aq.push(make_pair(d[to], to));
            }
        }
    }
    int minPath = d[n - 1];
    cout << maxWeight << " " << minPath << endl;
}
int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}