結果

問題 No.1473 おでぶなおばけさん
ユーザー Kome_soudouKome_soudou
提出日時 2022-03-23 13:30:05
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,025 bytes
コンパイル時間 1,784 ms
コンパイル使用メモリ 173,276 KB
実行使用メモリ 11,816 KB
最終ジャッジ日時 2024-04-19 19:03:39
合計ジャッジ時間 9,991 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 187 ms
11,468 KB
testcase_03 AC 135 ms
10,368 KB
testcase_04 AC 104 ms
7,728 KB
testcase_05 AC 43 ms
5,376 KB
testcase_06 AC 186 ms
10,856 KB
testcase_07 AC 172 ms
11,692 KB
testcase_08 AC 223 ms
11,816 KB
testcase_09 AC 165 ms
11,688 KB
testcase_10 AC 94 ms
7,424 KB
testcase_11 AC 95 ms
8,832 KB
testcase_12 AC 97 ms
8,192 KB
testcase_13 AC 60 ms
6,528 KB
testcase_14 AC 42 ms
5,376 KB
testcase_15 AC 82 ms
7,680 KB
testcase_16 AC 93 ms
7,040 KB
testcase_17 AC 8 ms
5,376 KB
testcase_18 AC 13 ms
5,376 KB
testcase_19 AC 82 ms
7,664 KB
testcase_20 AC 108 ms
9,536 KB
testcase_21 AC 129 ms
9,296 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 221 ms
10,540 KB
testcase_26 AC 234 ms
10,772 KB
testcase_27 AC 67 ms
6,156 KB
testcase_28 AC 203 ms
11,568 KB
testcase_29 AC 133 ms
9,344 KB
testcase_30 AC 172 ms
10,240 KB
testcase_31 AC 137 ms
11,504 KB
testcase_32 AC 143 ms
11,220 KB
testcase_33 AC 108 ms
9,508 KB
testcase_34 AC 57 ms
6,788 KB
testcase_35 AC 62 ms
6,912 KB
testcase_36 AC 114 ms
8,392 KB
testcase_37 AC 131 ms
9,128 KB
testcase_38 AC 25 ms
5,376 KB
testcase_39 AC 92 ms
7,040 KB
testcase_40 AC 93 ms
7,040 KB
testcase_41 AC 81 ms
6,744 KB
testcase_42 AC 86 ms
6,488 KB
testcase_43 AC 99 ms
9,068 KB
testcase_44 AC 96 ms
9,192 KB
testcase_45 AC 98 ms
9,064 KB
testcase_46 AC 112 ms
9,088 KB
testcase_47 AC 141 ms
10,240 KB
testcase_48 AC 131 ms
9,688 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/istream:41,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/sstream:40,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/x86_64-pc-linux-gnu/bits/stdc++.h:127,
                 from main.cpp:1:
In member function 'std::basic_ostream<_CharT, _Traits>::__ostream_type& std::basic_ostream<_CharT, _Traits>::operator<<(long int) [with _CharT = char; _Traits = std::char_traits<char>]',
    inlined from 'int main()' at main.cpp:64:23:
/home/linuxbrew/.linuxbrew/Cellar/gcc/13.2.0/include/c++/13/ostream:169:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  169 |       { return _M_insert(__n); }
      |                ~~~~~~~~~^~~~~
main.cpp: In function 'int main()':
main.cpp:33:17: note: 'ans' was declared here
   33 |         int64_t ans;
      |                 ^~~

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

struct Edge
{
	int64_t to; // 辺の行先
	int64_t weight; // 辺の重み
	Edge(int64_t t, int64_t w) : to(t), weight(w){} 
};

using Graph = vector<vector<Edge>>;

int main()
{
	int64_t N, M;
	cin >> N >> M;
	
	Graph G(N);
	int64_t S, T, D;
	for(int64_t i = 0; i < M; i++)
	{
		cin >> S >> T >> D;
		S--; T--;
		G[S].push_back(Edge(T, D));
		G[T].push_back(Edge(S, D));
	}
	
	int64_t ok = 1;
	int64_t ng = 1000000001;
	int64_t mid;
	const int64_t inf = 1000000001;
	queue<int64_t> q;
	int64_t ans;
	while(ng - ok != 1)
	{
		mid = (ng + ok) / 2;
		vector<int64_t> dist(N, inf);
		dist[0] = 0;
		q.push(0);
		while(!q.empty())
		{
			int64_t p = q.front();
			q.pop();
			
			for(Edge e : G[p])
			{
				if(e.weight < mid) continue;
				if(dist[p] + 1 < dist[e.to])
				{
					dist[e.to] = dist[p] + 1;
					q.push(e.to);
				}
			}
		}
		
		if(dist[N - 1] != inf)
		{
			ok = mid;
			ans = dist[N - 1];
		}
		else ng = mid;
	}
	
	cout << ok << ' ' << ans << endl;
	return 0;
}
0