結果

問題 No.807 umg tours
ユーザー ahe100ahe100
提出日時 2019-03-22 22:08:51
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,024 bytes
コンパイル時間 3,421 ms
コンパイル使用メモリ 172,352 KB
実行使用メモリ 22,508 KB
最終ジャッジ日時 2023-08-15 11:59:22
合計ジャッジ時間 13,322 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
9,508 KB
testcase_01 AC 5 ms
9,520 KB
testcase_02 AC 5 ms
9,664 KB
testcase_03 AC 4 ms
9,600 KB
testcase_04 AC 4 ms
9,468 KB
testcase_05 AC 5 ms
9,584 KB
testcase_06 AC 5 ms
9,660 KB
testcase_07 AC 5 ms
9,516 KB
testcase_08 AC 4 ms
9,452 KB
testcase_09 AC 4 ms
9,460 KB
testcase_10 AC 4 ms
9,464 KB
testcase_11 AC 282 ms
19,136 KB
testcase_12 AC 243 ms
16,804 KB
testcase_13 AC 346 ms
19,700 KB
testcase_14 AC 139 ms
13,912 KB
testcase_15 AC 112 ms
13,260 KB
testcase_16 AC 371 ms
20,060 KB
testcase_17 AC 457 ms
21,980 KB
testcase_18 AC 479 ms
22,292 KB
testcase_19 AC 454 ms
22,508 KB
testcase_20 AC 252 ms
16,628 KB
testcase_21 AC 254 ms
16,892 KB
testcase_22 AC 105 ms
12,848 KB
testcase_23 AC 83 ms
12,116 KB
testcase_24 TLE -
testcase_25 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll mod = 1e9+7;
//LLONG_MIN

/*

*/

ll n,m,d[2][100010];
vector<ll> v[100010],c[100010];
queue<ll> Q;

int main(void){
	cin>>n>>m;
	rep(i,m){
		ll a,b,x;
		cin>>a>>b>>x;
		v[a].push_back(b);
		v[b].push_back(a);
		c[a].push_back(x);
		c[b].push_back(x);
	}
	reg(i,1,n){
		d[0][i]=1e18;
		d[1][i]=1e18;
	}
	d[0][1]=0;
	d[1][1]=0;
	Q.push(1);
	while(!Q.empty()){
		ll p=Q.front();Q.pop();
		rep(i,v[p].size()){
			bool ok=false;
			ll q=v[p][i],di=c[p][i];
			if(d[0][q]>d[0][p]+di){
				d[0][q]=d[0][p]+di;
				ok=true;
			}
			if(d[1][q]>min(d[0][p],d[1][p]+di)){
				d[1][q]=min(d[0][p],d[1][p]+di);
				ok=true;
			}
			if(ok)Q.push(q);
		}
	}
	reg(i,1,n){
		cout<<d[1][i]+d[0][i]<<endl;
	}
	return 0;
}
0