結果

問題 No.1473 おでぶなおばけさん
ユーザー nuxxppnuxxpp
提出日時 2021-04-11 02:36:38
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 2,064 bytes
コンパイル時間 3,822 ms
コンパイル使用メモリ 162,196 KB
実行使用メモリ 16,444 KB
最終ジャッジ日時 2023-09-09 05:50:50
合計ジャッジ時間 13,952 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
12,932 KB
testcase_01 AC 4 ms
5,816 KB
testcase_02 AC 1,345 ms
10,276 KB
testcase_03 AC 232 ms
9,492 KB
testcase_04 AC 605 ms
8,108 KB
testcase_05 AC 310 ms
6,756 KB
testcase_06 AC 900 ms
9,848 KB
testcase_07 AC 222 ms
9,940 KB
testcase_08 AC 424 ms
9,948 KB
testcase_09 AC 186 ms
9,800 KB
testcase_10 AC 47 ms
7,736 KB
testcase_11 AC 55 ms
8,684 KB
testcase_12 AC 44 ms
8,200 KB
testcase_13 AC 23 ms
7,108 KB
testcase_14 AC 18 ms
6,776 KB
testcase_15 AC 33 ms
7,836 KB
testcase_16 AC 42 ms
7,436 KB
testcase_17 AC 6 ms
5,912 KB
testcase_18 AC 8 ms
6,144 KB
testcase_19 AC 150 ms
8,044 KB
testcase_20 AC 262 ms
8,956 KB
testcase_21 AC 700 ms
9,992 KB
testcase_22 AC 178 ms
10,100 KB
testcase_23 AC 150 ms
8,912 KB
testcase_24 AC 145 ms
9,664 KB
testcase_25 TLE -
testcase_26 -- -
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 diks(int, 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.first][i];
      |            ^
main.cpp: 関数 ‘int main()’ 内:
main.cpp:98:23: 警告: ‘count’ may be used uninitialized [-Wmaybe-uninitialized]
   98 |   cout << l << " " << count << endl;
      |                       ^~~~~
main.cpp:86:27: 備考: ‘count’ はここで定義されています
   86 |   int l = 0, r = 1e9 + 1, count;
      |                           ^~~~~

ソースコード

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 diks(int s, int goal, int ma) {
  priority_queue<P, vector<P>, greater<P>> que;
  vector<int> d(n, INF);
  que.push(P(s,  0));
  d[s] = 0;

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

  return -1;
}


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 l = 0, r = 1e9 + 1, count;
  while(r - 1 > l) {
    int mid = (r + l) / 2;
    int t = diks(0, n - 1, mid);
    if(t == -1) {
      r = mid;
    } else {
      l = mid;
      count = t;
    }
  }

  cout << l << " " << count << endl;
}
0