結果

問題 No.1473 おでぶなおばけさん
ユーザー kotatsugamekotatsugame
提出日時 2021-04-09 21:37:21
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 169 ms / 2,000 ms
コード長 1,060 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 78,848 KB
実行使用メモリ 11,172 KB
最終ジャッジ日時 2023-09-07 10:19:30
合計ジャッジ時間 7,900 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,416 KB
testcase_01 AC 3 ms
6,420 KB
testcase_02 AC 163 ms
11,172 KB
testcase_03 AC 130 ms
10,380 KB
testcase_04 AC 83 ms
9,092 KB
testcase_05 AC 29 ms
7,388 KB
testcase_06 AC 151 ms
10,532 KB
testcase_07 AC 160 ms
10,896 KB
testcase_08 AC 169 ms
10,872 KB
testcase_09 AC 159 ms
10,852 KB
testcase_10 AC 82 ms
8,368 KB
testcase_11 AC 83 ms
9,384 KB
testcase_12 AC 83 ms
8,632 KB
testcase_13 AC 51 ms
7,728 KB
testcase_14 AC 37 ms
7,236 KB
testcase_15 AC 70 ms
8,648 KB
testcase_16 AC 80 ms
8,192 KB
testcase_17 AC 9 ms
6,636 KB
testcase_18 AC 12 ms
6,840 KB
testcase_19 AC 77 ms
8,780 KB
testcase_20 AC 108 ms
10,196 KB
testcase_21 AC 115 ms
9,624 KB
testcase_22 AC 127 ms
10,392 KB
testcase_23 AC 109 ms
10,096 KB
testcase_24 AC 107 ms
9,836 KB
testcase_25 AC 148 ms
10,292 KB
testcase_26 AC 154 ms
10,480 KB
testcase_27 AC 51 ms
7,964 KB
testcase_28 AC 156 ms
10,796 KB
testcase_29 AC 123 ms
10,012 KB
testcase_30 AC 144 ms
10,464 KB
testcase_31 AC 162 ms
10,852 KB
testcase_32 AC 146 ms
10,724 KB
testcase_33 AC 116 ms
9,916 KB
testcase_34 AC 56 ms
8,404 KB
testcase_35 AC 63 ms
8,488 KB
testcase_36 AC 95 ms
9,108 KB
testcase_37 AC 114 ms
9,620 KB
testcase_38 AC 22 ms
7,172 KB
testcase_39 AC 81 ms
8,468 KB
testcase_40 AC 81 ms
8,400 KB
testcase_41 AC 70 ms
7,968 KB
testcase_42 AC 69 ms
8,232 KB
testcase_43 AC 106 ms
9,760 KB
testcase_44 AC 106 ms
9,952 KB
testcase_45 AC 106 ms
9,896 KB
testcase_46 AC 97 ms
9,424 KB
testcase_47 AC 117 ms
10,252 KB
testcase_48 AC 104 ms
9,656 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
   10 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
using namespace std;
int N,M;
vector<pair<int,int> >G[1<<17];
int dist[1<<17];
int cnt[1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int u,v,d;cin>>u>>v>>d;
		u--,v--;
		G[u].push_back(make_pair(v,d));
		G[v].push_back(make_pair(u,d));
	}
	dist[0]=2e9;
	priority_queue<pair<int,int> >P;
	P.push(make_pair(dist[0],0));
	while(!P.empty())
	{
		int cost=P.top().first;
		int u=P.top().second;
		P.pop();
		if(dist[u]>cost)continue;
		for(pair<int,int>e:G[u])
		{
			int v=e.first;
			int nxt=min(cost,e.second);
			if(dist[v]<nxt)
			{
				dist[v]=nxt;
				P.push(make_pair(nxt,v));
			}
		}
	}
	int W=dist[N-1];
	for(int i=0;i<N;i++)cnt[i]=1e9;
	cnt[0]=0;
	P.push(make_pair(0,0));
	while(!P.empty())
	{
		int cost=-P.top().first;
		int u=P.top().second;
		P.pop();
		if(cnt[u]<cost)continue;
		for(pair<int,int>e:G[u])if(e.second>=W)
		{
			int v=e.first;
			if(cnt[v]>cost+1)
			{
				cnt[v]=cost+1;
				P.push(make_pair(-cnt[v],v));
			}
		}
	}
	cout<<W<<" "<<cnt[N-1]<<endl;
}
0