結果

問題 No.1473 おでぶなおばけさん
ユーザー nuxxppnuxxpp
提出日時 2021-04-11 02:26:02
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 78 ms / 2,000 ms
コード長 2,341 bytes
コンパイル時間 3,375 ms
コンパイル使用メモリ 165,760 KB
実行使用メモリ 10,024 KB
最終ジャッジ日時 2023-09-09 05:43:49
合計ジャッジ時間 7,476 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,828 KB
testcase_01 AC 3 ms
5,800 KB
testcase_02 AC 78 ms
9,856 KB
testcase_03 AC 54 ms
9,472 KB
testcase_04 AC 36 ms
8,032 KB
testcase_05 AC 15 ms
6,716 KB
testcase_06 AC 63 ms
9,776 KB
testcase_07 AC 73 ms
9,860 KB
testcase_08 AC 73 ms
9,860 KB
testcase_09 AC 67 ms
10,024 KB
testcase_10 AC 32 ms
7,820 KB
testcase_11 AC 32 ms
8,604 KB
testcase_12 AC 31 ms
8,112 KB
testcase_13 AC 20 ms
6,980 KB
testcase_14 AC 15 ms
6,800 KB
testcase_15 AC 27 ms
7,868 KB
testcase_16 AC 30 ms
7,620 KB
testcase_17 AC 6 ms
6,008 KB
testcase_18 AC 7 ms
6,228 KB
testcase_19 AC 35 ms
8,148 KB
testcase_20 AC 43 ms
8,808 KB
testcase_21 AC 56 ms
8,980 KB
testcase_22 AC 63 ms
9,632 KB
testcase_23 AC 47 ms
8,872 KB
testcase_24 AC 49 ms
8,808 KB
testcase_25 AC 62 ms
9,664 KB
testcase_26 AC 53 ms
9,640 KB
testcase_27 AC 22 ms
7,280 KB
testcase_28 AC 60 ms
9,736 KB
testcase_29 AC 46 ms
8,664 KB
testcase_30 AC 57 ms
9,380 KB
testcase_31 AC 76 ms
9,836 KB
testcase_32 AC 64 ms
9,920 KB
testcase_33 AC 57 ms
9,020 KB
testcase_34 AC 23 ms
7,524 KB
testcase_35 AC 30 ms
7,836 KB
testcase_36 AC 45 ms
8,396 KB
testcase_37 AC 46 ms
8,800 KB
testcase_38 AC 11 ms
6,300 KB
testcase_39 AC 30 ms
7,592 KB
testcase_40 AC 32 ms
7,580 KB
testcase_41 AC 27 ms
7,204 KB
testcase_42 AC 27 ms
7,276 KB
testcase_43 AC 41 ms
9,976 KB
testcase_44 AC 41 ms
9,988 KB
testcase_45 AC 40 ms
9,936 KB
testcase_46 AC 45 ms
8,656 KB
testcase_47 AC 59 ms
9,108 KB
testcase_48 AC 50 ms
8,692 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: 関数 ‘int di_m(int, int)’ 内:
main.cpp:60:12: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   60 |       auto [v, w] = g[e.now][i];
      |            ^
main.cpp: 関数 ‘int diks(int, int, int)’ 内:
main.cpp:79:12: 警告: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions]
   79 |       auto [v, w] = g[e.now][i];
      |            ^
main.cpp: 関数 ‘int di_m(int, int)’ 内:
main.cpp:67:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   67 | }
      | ^
main.cpp: 関数 ‘int diks(int, int, int)’ 内:
main.cpp:86:1: 警告: 制御が非 void 関数の終りに到達しました [-Wreturn-type]
   86 | }
      | ^

ソースコード

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;
  }

  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, vector<edge>, greater<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