結果

問題 No.1473 おでぶなおばけさん
ユーザー kwm_tkwm_t
提出日時 2021-04-10 18:54:52
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 1,449 bytes
コンパイル時間 2,623 ms
コンパイル使用メモリ 172,336 KB
実行使用メモリ 10,008 KB
最終ジャッジ日時 2023-09-08 14:42:15
合計ジャッジ時間 7,744 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
5,728 KB
testcase_01 AC 3 ms
5,864 KB
testcase_02 AC 89 ms
9,736 KB
testcase_03 AC 70 ms
9,160 KB
testcase_04 AC 64 ms
7,824 KB
testcase_05 AC 27 ms
6,496 KB
testcase_06 AC 104 ms
9,604 KB
testcase_07 AC 97 ms
10,008 KB
testcase_08 AC 130 ms
9,812 KB
testcase_09 AC 83 ms
9,764 KB
testcase_10 AC 35 ms
7,660 KB
testcase_11 AC 37 ms
8,596 KB
testcase_12 AC 35 ms
8,068 KB
testcase_13 AC 23 ms
6,964 KB
testcase_14 AC 17 ms
6,772 KB
testcase_15 AC 32 ms
7,908 KB
testcase_16 AC 34 ms
7,432 KB
testcase_17 AC 6 ms
5,812 KB
testcase_18 AC 8 ms
6,144 KB
testcase_19 AC 40 ms
8,100 KB
testcase_20 AC 54 ms
8,768 KB
testcase_21 AC 66 ms
8,728 KB
testcase_22 AC 46 ms
9,416 KB
testcase_23 AC 38 ms
8,700 KB
testcase_24 AC 40 ms
8,992 KB
testcase_25 AC 130 ms
9,396 KB
testcase_26 AC 131 ms
9,420 KB
testcase_27 AC 37 ms
7,060 KB
testcase_28 AC 100 ms
9,700 KB
testcase_29 AC 69 ms
8,768 KB
testcase_30 AC 86 ms
9,376 KB
testcase_31 AC 77 ms
9,696 KB
testcase_32 AC 73 ms
9,528 KB
testcase_33 AC 56 ms
9,060 KB
testcase_34 AC 33 ms
7,360 KB
testcase_35 AC 32 ms
7,500 KB
testcase_36 AC 56 ms
8,176 KB
testcase_37 AC 75 ms
8,600 KB
testcase_38 AC 14 ms
6,280 KB
testcase_39 AC 35 ms
7,376 KB
testcase_40 AC 35 ms
7,652 KB
testcase_41 AC 33 ms
7,148 KB
testcase_42 AC 33 ms
7,252 KB
testcase_43 AC 38 ms
8,172 KB
testcase_44 AC 39 ms
8,152 KB
testcase_45 AC 39 ms
8,176 KB
testcase_46 AC 61 ms
8,628 KB
testcase_47 AC 83 ms
9,112 KB
testcase_48 AC 71 ms
8,700 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
//#include "atcoder/all"
using namespace std;
//using namespace atcoder;
//using mint = modint1000000007;
//const int mod = 1000000007;
//using mint = modint998244353;
//const int mod = 998244353;
const int INF = 1e9;
const long long LINF = 1e18;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep2(i,l,r)for(int i=(l);i<(r);++i)
#define rrep(i, n) for (int i = (n-1); i >= 0; --i)
#define rrep2(i,l,r)for(int i=(r-1);i>=(l);--i)
#define all(x) (x).begin(),(x).end()
#define allR(x) (x).rbegin(),(x).rend()
#define endl "\n"
int n, m;
struct Edge {
	int to, w;
	Edge(int to, int w) :to(to), w(w) {}
};
vector<Edge>g[100005];
int f(long long x) {
	vector<int>d(n, INF);
	queue<int> q;
	q.emplace(0);
	d[0] = 0;
	while (!q.empty()) {
		int now = q.front();
		q.pop();
		for (auto e : g[now]) {
			if (e.w < x) { continue; }
			if (d[e.to] > d[now] + 1) {
				d[e.to] = d[now] + 1;
				q.emplace(e.to);
			}
		}
	}
	if (INF == d[n - 1]) {
		return -1;
	}
	return d[n - 1];
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cin >> n >> m;
	rep(i, m) {
		int s, t, d;
		cin >> s >> t >> d;
		s--;
		t--;
		g[s].emplace_back(t, d);
		g[t].emplace_back(s, d);
	}
	long long ng = INF + 1;
	long long ok = 0;
	int ans = 0;
	while (1 < abs(ok - ng)) {
		long long c = (ng + ok) / 2;
		int ret = f(c);
		if (-1 != ret) { ok = c; ans = ret; }
		else { ng = c; }
	}
	cout << ok << " " << ans << endl;
	return 0;
}
0