結果

問題 No.1601 With Animals into Institute
ユーザー kotatsugamekotatsugame
提出日時 2021-07-10 18:48:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 509 ms / 3,000 ms
コード長 884 bytes
コンパイル時間 733 ms
コンパイル使用メモリ 80,964 KB
実行使用メモリ 16,896 KB
最終ジャッジ日時 2023-09-14 19:49:11
合計ジャッジ時間 9,355 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 3 ms
6,340 KB
testcase_01 AC 3 ms
6,460 KB
testcase_02 AC 3 ms
6,528 KB
testcase_03 AC 9 ms
6,640 KB
testcase_04 AC 9 ms
6,704 KB
testcase_05 AC 10 ms
6,740 KB
testcase_06 AC 492 ms
16,740 KB
testcase_07 AC 480 ms
16,620 KB
testcase_08 AC 488 ms
16,712 KB
testcase_09 AC 491 ms
16,644 KB
testcase_10 AC 506 ms
16,724 KB
testcase_11 AC 506 ms
16,720 KB
testcase_12 AC 505 ms
16,612 KB
testcase_13 AC 509 ms
16,736 KB
testcase_14 AC 494 ms
16,700 KB
testcase_15 AC 481 ms
16,600 KB
testcase_16 AC 486 ms
16,896 KB
testcase_17 AC 494 ms
16,668 KB
testcase_18 AC 10 ms
6,924 KB
testcase_19 AC 10 ms
6,748 KB
testcase_20 AC 10 ms
6,844 KB
testcase_21 AC 10 ms
6,664 KB
testcase_22 AC 9 ms
6,844 KB
testcase_23 AC 9 ms
6,688 KB
testcase_24 AC 9 ms
6,688 KB
testcase_25 AC 9 ms
6,680 KB
testcase_26 AC 10 ms
6,900 KB
testcase_27 AC 3 ms
6,440 KB
testcase_28 AC 3 ms
6,368 KB
testcase_29 AC 3 ms
6,360 KB
testcase_30 AC 3 ms
6,340 KB
testcase_31 AC 3 ms
6,432 KB
testcase_32 AC 3 ms
6,460 KB
testcase_33 AC 3 ms
6,364 KB
testcase_34 AC 4 ms
6,356 KB
testcase_35 AC 3 ms
6,312 KB
testcase_36 AC 3 ms
6,428 KB
testcase_37 AC 3 ms
6,460 KB
testcase_38 AC 3 ms
6,340 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:8:1: 警告: ISO C++ では型の無い ‘main’ の宣言を禁止しています [-Wreturn-type]
    8 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<vector>
#include<queue>
using namespace std;
int N,M;
vector<pair<int,pair<int,bool> > >G[1<<17];
long D[2][1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<M;i++)
	{
		int a,b,c,x;cin>>a>>b>>c>>x;
		a--,b--;
		G[a].push_back(make_pair(b,make_pair(c,x)));
		G[b].push_back(make_pair(a,make_pair(c,x)));
	}
	for(int i=0;i<2;i++)for(int j=0;j<N;j++)D[i][j]=1e18;
	priority_queue<pair<long,pair<int,int> > >P;
	D[0][N-1]=0;
	P.push(make_pair(0,make_pair(0,N-1)));
	while(!P.empty())
	{
		int w=P.top().second.first,u=P.top().second.second;
		long c=-P.top().first;
		P.pop();
		if(D[w][u]<c)continue;
		for(pair<int,pair<int,bool> >e:G[u])
		{
			int v=e.first;
			long nc=c+e.second.first;
			int nw=w||e.second.second;
			if(D[nw][v]>nc)
			{
				D[nw][v]=nc;
				P.push(make_pair(-nc,make_pair(nw,v)));
			}
		}
	}
	for(int i=0;i<N-1;i++)cout<<D[1][i]<<endl;
}
0