結果

問題 No.1473 おでぶなおばけさん
ユーザー tkmst201tkmst201
提出日時 2021-06-13 11:35:29
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 141 ms / 2,000 ms
コード長 1,358 bytes
コンパイル時間 3,044 ms
コンパイル使用メモリ 212,320 KB
実行使用メモリ 9,472 KB
最終ジャッジ日時 2023-08-23 13:17:29
合計ジャッジ時間 10,154 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 139 ms
9,436 KB
testcase_03 AC 124 ms
8,836 KB
testcase_04 AC 73 ms
6,376 KB
testcase_05 AC 26 ms
4,556 KB
testcase_06 AC 132 ms
8,764 KB
testcase_07 AC 141 ms
9,212 KB
testcase_08 AC 135 ms
9,328 KB
testcase_09 AC 139 ms
9,472 KB
testcase_10 AC 80 ms
5,420 KB
testcase_11 AC 81 ms
6,224 KB
testcase_12 AC 81 ms
5,736 KB
testcase_13 AC 49 ms
4,500 KB
testcase_14 AC 36 ms
4,380 KB
testcase_15 AC 68 ms
5,448 KB
testcase_16 AC 78 ms
5,268 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 10 ms
4,380 KB
testcase_19 AC 72 ms
5,896 KB
testcase_20 AC 102 ms
7,968 KB
testcase_21 AC 109 ms
6,928 KB
testcase_22 AC 105 ms
8,788 KB
testcase_23 AC 84 ms
7,832 KB
testcase_24 AC 85 ms
7,960 KB
testcase_25 AC 123 ms
8,532 KB
testcase_26 AC 129 ms
8,604 KB
testcase_27 AC 47 ms
4,844 KB
testcase_28 AC 140 ms
9,252 KB
testcase_29 AC 111 ms
7,312 KB
testcase_30 AC 131 ms
8,240 KB
testcase_31 AC 128 ms
9,428 KB
testcase_32 AC 126 ms
9,316 KB
testcase_33 AC 96 ms
8,088 KB
testcase_34 AC 48 ms
5,584 KB
testcase_35 AC 57 ms
5,556 KB
testcase_36 AC 86 ms
6,328 KB
testcase_37 AC 93 ms
7,428 KB
testcase_38 AC 19 ms
4,376 KB
testcase_39 AC 79 ms
4,968 KB
testcase_40 AC 79 ms
5,176 KB
testcase_41 AC 68 ms
4,796 KB
testcase_42 AC 67 ms
4,712 KB
testcase_43 AC 98 ms
7,732 KB
testcase_44 AC 99 ms
7,736 KB
testcase_45 AC 98 ms
7,984 KB
testcase_46 AC 90 ms
7,332 KB
testcase_47 AC 109 ms
8,088 KB
testcase_48 AC 97 ms
7,480 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) begin(v),end(v)
template<typename A, typename B> inline bool chmax(A & a, const B & b) { if (a < b) { a = b; return true; } return false; }
template<typename A, typename B> inline bool chmin(A & a, const B & b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using pii = pair<int, int>;
constexpr ll INF = 1ll<<30;
constexpr ll longINF = 1ll<<60;
constexpr ll MOD = 1000000007;
constexpr bool debug = false;
//---------------------------------//

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<pii>> g(N);
	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);
	}
	
	vector<int> dist(N, -INF);
	priority_queue<pii> pq;
	dist[0] = INF;
	pq.emplace(INF, 0);
	while (!pq.empty()) {
		auto [d, u] = pq.top(); pq.pop();
		if (dist[u] != d) continue;
		for (auto [v, dis] : g[u]) if (chmax(dist[v], min(d, dis))) pq.emplace(dist[v], v);
	}
	
	int mx = dist[N - 1];
	
	dist.assign(N, INF);
	queue<int> que;
	dist[0] = 0;
	que.emplace(0);
	while (!que.empty()) {
		int u = que.front(); que.pop();
		for (auto [v, dis] : g[u]) if (dis >= mx && chmin(dist[v], dist[u] + 1)) que.emplace(v);
	}
	
	cout << mx << " " << dist[N - 1] << endl;
}
0