結果

問題 No.1473 おでぶなおばけさん
ユーザー nuxxppnuxxpp
提出日時 2021-04-11 02:18:04
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 2,243 bytes
コンパイル時間 3,093 ms
コンパイル使用メモリ 163,776 KB
実行使用メモリ 14,156 KB
最終ジャッジ日時 2023-09-09 05:37:21
合計ジャッジ時間 9,399 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
12,952 KB
testcase_01 AC 4 ms
5,980 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 AC 67 ms
9,884 KB
testcase_08 WA -
testcase_09 AC 63 ms
9,784 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 32 ms
8,100 KB
testcase_13 AC 20 ms
7,076 KB
testcase_14 AC 15 ms
6,704 KB
testcase_15 AC 26 ms
7,752 KB
testcase_16 WA -
testcase_17 AC 5 ms
5,912 KB
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 TLE -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int di_m(int, int)’ 内:
main.cpp:56:12: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   56 |       auto [v, w] = g[e.now][i];
      |            ^
main.cpp: 関数 ‘int diks(int, int, int)’ 内:
main.cpp:75:12: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   75 |       auto [v, w] = g[e.now][i];
      |            ^
main.cpp: 関数 ‘int di_m(int, int)’ 内:
main.cpp:63:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   63 | }
      | ^
main.cpp: 関数 ‘int diks(int, int, int)’ 内:
main.cpp:82:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   82 | }
      | ^

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <deque>
#include <stack>
#include <atcoder/all>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < (t); ++i)
#define dsrep(i,t,s) for(int i = (t)-1; i >= (s); --i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const ll mod = 998244353;

////////////////////////////////////////////
int n, m;
vector<P> g[100005];
struct edge
{
  int now, front, we;
  bool operator< (edge edge2) const {
    return we < edge2.we;
  }
};

int di_m(int s, int goal) {
  priority_queue<edge> que;
  vector<int> d(n, -1);
  que.push(edge{s, -1, INF});

  while (!que.empty()) {
    edge e = que.top(); que.pop();
    if(d[e.now] > e.we) continue;
    if(e.now == goal) return e.we;
    for(int i = 0; i < g[e.now].size(); i++) {
      auto [v, w] = g[e.now][i];
      if(d[v] < min(e.we, w)) {
        d[v] = min(e.we, w);
        que.push(edge{v, e.now, d[v]});
      }
    }
  }
}

int diks(int s, int goal, int ma) {
  priority_queue<edge> que;
  vector<int> d(n, INF);
  que.push(edge{s, -1, 0});
  d[s] = 0;

  while (!que.empty()) {
    edge e = que.top(); que.pop();
    if(e.now == goal) return e.we;
    for(int i = 0; i < g[e.now].size(); i++) {
      auto [v, w] = g[e.now][i];
      if(w >= ma && d[v] > e.we + 1) {
        d[v] = e.we + 1;
        que.push(edge{v, e.now, d[v]});
      }
    }
  }
}



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

  cin >> n >> m;

  int a, b, c;
  rep(i, m) {
    cin >> a >> b >> c;
    a--; b--;
    g[a].push_back(P(b, c));
    g[b].push_back(P(a, c));
  }

  int ma = di_m(0, n - 1);
  cout << ma << " " << diks(0, n - 1, ma) << endl;
}
0