結果
| 問題 | No.1601 With Animals into Institute | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2021-07-10 18:48:25 | 
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 526 ms / 3,000 ms | 
| コード長 | 884 bytes | 
| コンパイル時間 | 864 ms | 
| コンパイル使用メモリ | 81,596 KB | 
| 実行使用メモリ | 17,252 KB | 
| 最終ジャッジ日時 | 2024-07-02 02:44:32 | 
| 合計ジャッジ時間 | 9,410 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge5 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 36 | 
コンパイルメッセージ
main.cpp:8:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    8 | main()
      | ^~~~
            
            ソースコード
#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;
}
            
            
            
        