結果

問題 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,776 ms
コンパイル使用メモリ 176,996 KB
実行使用メモリ 11,820 KB
最終ジャッジ日時 2024-10-11 11:14:31
合計ジャッジ時間 10,643 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,248 KB
testcase_02 AC 204 ms
11,472 KB
testcase_03 AC 144 ms
10,368 KB
testcase_04 AC 109 ms
7,732 KB
testcase_05 AC 43 ms
5,248 KB
testcase_06 AC 198 ms
10,980 KB
testcase_07 AC 183 ms
11,820 KB
testcase_08 AC 234 ms
11,696 KB
testcase_09 AC 180 ms
11,820 KB
testcase_10 AC 96 ms
7,424 KB
testcase_11 AC 98 ms
8,960 KB
testcase_12 AC 96 ms
8,320 KB
testcase_13 AC 60 ms
6,400 KB
testcase_14 AC 43 ms
5,504 KB
testcase_15 AC 82 ms
7,680 KB
testcase_16 AC 91 ms
6,912 KB
testcase_17 AC 8 ms
5,248 KB
testcase_18 AC 13 ms
5,248 KB
testcase_19 AC 84 ms
7,552 KB
testcase_20 AC 111 ms
9,664 KB
testcase_21 AC 132 ms
9,300 KB
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 226 ms
10,404 KB
testcase_26 AC 229 ms
10,624 KB
testcase_27 AC 68 ms
6,036 KB
testcase_28 AC 211 ms
11,568 KB
testcase_29 AC 134 ms
9,344 KB
testcase_30 AC 173 ms
10,240 KB
testcase_31 AC 147 ms
11,512 KB
testcase_32 AC 153 ms
11,092 KB
testcase_33 AC 115 ms
9,508 KB
testcase_34 AC 59 ms
6,532 KB
testcase_35 AC 63 ms
6,784 KB
testcase_36 AC 115 ms
8,272 KB
testcase_37 AC 139 ms
9,124 KB
testcase_38 AC 25 ms
5,248 KB
testcase_39 AC 94 ms
6,912 KB
testcase_40 AC 92 ms
6,912 KB
testcase_41 AC 84 ms
6,616 KB
testcase_42 AC 83 ms
6,480 KB
testcase_43 AC 99 ms
9,064 KB
testcase_44 AC 99 ms
9,064 KB
testcase_45 AC 99 ms
9,192 KB
testcase_46 AC 116 ms
9,216 KB
testcase_47 AC 145 ms
10,368 KB
testcase_48 AC 135 ms
9,820 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
In file included from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/istream:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/sstream:38,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/complex:45,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/ccomplex:39,
                 from /home/linuxbrew/.linuxbrew/Cellar/gcc@12/12.3.0/include/c++/12/x86_64-pc-linux-gnu/bits/stdc++.h:54,
                 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@12/12.3.0/include/c++/12/ostream:167:25: warning: 'ans' may be used uninitialized [-Wmaybe-uninitialized]
  167 |       { 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