結果

問題 No.1601 With Animals into Institute
ユーザー 沙耶花沙耶花
提出日時 2021-07-10 14:05:44
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 424 ms / 3,000 ms
コード長 1,082 bytes
コンパイル時間 4,398 ms
コンパイル使用メモリ 265,256 KB
実行使用メモリ 18,796 KB
最終ジャッジ日時 2023-09-14 19:13:42
合計ジャッジ時間 11,975 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 5 ms
4,380 KB
testcase_04 AC 6 ms
4,376 KB
testcase_05 AC 6 ms
4,376 KB
testcase_06 AC 416 ms
18,524 KB
testcase_07 AC 417 ms
18,496 KB
testcase_08 AC 410 ms
18,796 KB
testcase_09 AC 419 ms
18,500 KB
testcase_10 AC 412 ms
18,648 KB
testcase_11 AC 424 ms
18,448 KB
testcase_12 AC 421 ms
18,588 KB
testcase_13 AC 419 ms
18,456 KB
testcase_14 AC 414 ms
18,568 KB
testcase_15 AC 418 ms
18,512 KB
testcase_16 AC 421 ms
18,516 KB
testcase_17 AC 420 ms
18,492 KB
testcase_18 AC 6 ms
4,380 KB
testcase_19 AC 6 ms
4,376 KB
testcase_20 AC 6 ms
4,376 KB
testcase_21 AC 5 ms
4,380 KB
testcase_22 AC 5 ms
4,376 KB
testcase_23 AC 6 ms
4,376 KB
testcase_24 AC 6 ms
4,376 KB
testcase_25 AC 6 ms
4,376 KB
testcase_26 AC 6 ms
4,376 KB
testcase_27 AC 1 ms
4,376 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 2 ms
4,376 KB
testcase_35 AC 2 ms
4,380 KB
testcase_36 AC 2 ms
4,376 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 2 ms
4,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using mint = modint1000000007;
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define Inf 1000000000000000000

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<long long> A(M),B(M),C(M),D(M);
	vector<vector<int>> E(N);
	
	rep(i,M){
		scanf("%lld %lld %lld %lld",&A[i],&B[i],&C[i],&D[i]);
		A[i]--;B[i]--;
		E[A[i]].push_back(i);
		E[B[i]].push_back(i);
	}
	vector<long long> dis(N*2,Inf);
	priority_queue<pair<long long,int>,vector<pair<long long,int>>,greater<pair<long long,int>>> Q;
	dis[N*2-1] = 0LL;
	Q.emplace(0,N*2-1);
	
	while(Q.size()>0){
		long long DD = Q.top().first;
		int u = Q.top().second/2,x = Q.top().second%2;
		Q.pop();
		if(DD != dis[u*2+x])continue;
		rep(i,E[u].size()){
			int ind = E[u][i];
			int v = A[ind] ^ B[ind] ^ u;
			int nx = x;
			if(D[ind])nx = 0;
			long long D2 = DD + C[ind];
			int temp = v*2 + nx;
			if(dis[temp]>D2){
				dis[temp] = D2;
				Q.emplace(D2,temp);
			}
		}
	}
	
	rep(i,N-1){
		cout<<dis[i*2]<<endl;
	}
	
	return 0;
}
0