結果

問題 No.1473 おでぶなおばけさん
ユーザー 沙耶花沙耶花
提出日時 2021-04-09 21:44:31
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 245 ms / 2,000 ms
コード長 898 bytes
コンパイル時間 4,778 ms
コンパイル使用メモリ 267,180 KB
実行使用メモリ 10,016 KB
最終ジャッジ日時 2023-09-07 10:37:46
合計ジャッジ時間 12,413 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 176 ms
9,344 KB
testcase_03 AC 139 ms
8,704 KB
testcase_04 AC 113 ms
6,772 KB
testcase_05 AC 42 ms
4,396 KB
testcase_06 AC 186 ms
8,804 KB
testcase_07 AC 177 ms
9,776 KB
testcase_08 AC 230 ms
10,016 KB
testcase_09 AC 169 ms
9,668 KB
testcase_10 AC 88 ms
5,212 KB
testcase_11 AC 89 ms
6,296 KB
testcase_12 AC 86 ms
5,744 KB
testcase_13 AC 53 ms
4,668 KB
testcase_14 AC 39 ms
4,380 KB
testcase_15 AC 75 ms
5,696 KB
testcase_16 AC 83 ms
5,216 KB
testcase_17 AC 7 ms
4,376 KB
testcase_18 AC 12 ms
4,376 KB
testcase_19 AC 79 ms
6,008 KB
testcase_20 AC 104 ms
8,128 KB
testcase_21 AC 128 ms
7,072 KB
testcase_22 AC 101 ms
8,348 KB
testcase_23 AC 82 ms
8,108 KB
testcase_24 AC 83 ms
7,740 KB
testcase_25 AC 231 ms
8,280 KB
testcase_26 AC 245 ms
8,444 KB
testcase_27 AC 64 ms
4,732 KB
testcase_28 AC 196 ms
9,700 KB
testcase_29 AC 131 ms
7,004 KB
testcase_30 AC 175 ms
7,748 KB
testcase_31 AC 152 ms
9,348 KB
testcase_32 AC 149 ms
9,028 KB
testcase_33 AC 110 ms
7,796 KB
testcase_34 AC 61 ms
5,732 KB
testcase_35 AC 62 ms
5,592 KB
testcase_36 AC 109 ms
6,208 KB
testcase_37 AC 139 ms
7,968 KB
testcase_38 AC 24 ms
4,376 KB
testcase_39 AC 85 ms
4,908 KB
testcase_40 AC 86 ms
5,192 KB
testcase_41 AC 77 ms
4,912 KB
testcase_42 AC 77 ms
4,896 KB
testcase_43 AC 94 ms
6,968 KB
testcase_44 AC 94 ms
7,068 KB
testcase_45 AC 94 ms
7,060 KB
testcase_46 AC 115 ms
7,304 KB
testcase_47 AC 145 ms
8,460 KB
testcase_48 AC 136 ms
8,172 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <atcoder/all>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000

vector<vector<pair<int,int>>> E;

int get(int m){
	vector<int> dis(E.size(),Inf);
	queue<int> Q;
	Q.push(0);
	dis[0] = 0;
	
	while(Q.size()>0){
		int u = Q.front();
		Q.pop();
		rep(i,E[u].size()){
			if(E[u][i].second < m)continue;
			int v = E[u][i].first;
			if(dis[v]!=Inf)continue;
			Q.push(v);
			dis[v] = dis[u]+1;
		}
	}
	return dis.back();
}

int main(){
	
	int n,m;
	cin>>n>>m;
	
	E.resize(n);
	
	rep(i,m){
		int s,t,d;
		cin>>s>>t>>d;
		s--;t--;
		E[s].emplace_back(t,d);
		E[t].emplace_back(s,d);
	}
	
	int ok = 0,ng = Inf+5;
	
	while(ng-ok>1){
		int mid = (ok+ng)/2;
		
		if(get(mid)==Inf)ng = mid;
		else ok = mid;
	}
	
	cout<<ok<<' '<<get(ok)<<endl;
	
    return 0;
}
0