Submission #52268894


Source Code Expand

// LUOGU_RID: 155515441
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fi first
#define se second
#define PII pair<int,int>
using namespace std;
const int N=2005;
vector<vector<PII>> G(N);
int vis[N];
signed main()
{
	int n,m;cin>>n>>m;
	for(int i=0;i<m;i++){
		int u,v,w;cin>>u>>v>>w;
		G[u].pb({v,w});
	}
	for(int i=1;i<=n;i++){
		memset(vis,0x7f,sizeof(vis));
		priority_queue<PII,vector<PII>,greater<PII>> Q;
		Q.push({0,i});
		while(!Q.empty())
		{
			int now=Q.top().se,val=Q.top().fi;
			Q.pop();
			for(auto it:G[now]){
				if(val+it.se<vis[it.fi]){
					vis[it.fi]=val+it.se;
					Q.push({val+it.se,it.fi});	
				}
			}
		}
		if(vis[i]>=1e17) cout<<-1<<endl;
		else cout<<vis[i]<<endl;
	}
}

Submission Info

Submission Time
Task E - Come Back Quickly
User gangbengr
Language C++ 20 (gcc 12.2)
Score 500
Code Size 763 Byte
Status AC
Exec Time 266 ms
Memory 3732 KiB

Judge Result

Set Name Sample All after_contest
Score / Max Score 0 / 0 500 / 500 0 / 0
Status
AC × 3
AC × 41
AC × 2
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All almost_path_00.txt, almost_path_01.txt, almost_path_02.txt, almost_path_03.txt, almost_path_04.txt, almost_path_05.txt, almost_path_06.txt, almost_path_07.txt, almost_path_08.txt, almost_path_09.txt, handmade_00.txt, handmade_01.txt, random_00.txt, random_01.txt, random_02.txt, random_03.txt, random_04.txt, random_05.txt, random_06.txt, random_07.txt, random_08.txt, random_09.txt, random_10.txt, random_11.txt, random_12.txt, random_13.txt, random_14.txt, random_15.txt, random_16.txt, random_17.txt, random_18.txt, random_19.txt, random_20.txt, random_21.txt, random_22.txt, random_23.txt, random_24.txt, sample_01.txt, sample_02.txt, sample_03.txt, wide_00.txt
after_contest after_contest_00.txt, after_contest_01.txt
Case Name Status Exec Time Memory
after_contest_00.txt AC 33 ms 3564 KiB
after_contest_01.txt AC 27 ms 3620 KiB
almost_path_00.txt AC 19 ms 3644 KiB
almost_path_01.txt AC 21 ms 3616 KiB
almost_path_02.txt AC 19 ms 3576 KiB
almost_path_03.txt AC 20 ms 3580 KiB
almost_path_04.txt AC 20 ms 3588 KiB
almost_path_05.txt AC 2 ms 3552 KiB
almost_path_06.txt AC 2 ms 3664 KiB
almost_path_07.txt AC 52 ms 3556 KiB
almost_path_08.txt AC 38 ms 3492 KiB
almost_path_09.txt AC 103 ms 3676 KiB
handmade_00.txt AC 1 ms 3452 KiB
handmade_01.txt AC 1 ms 3512 KiB
random_00.txt AC 6 ms 3732 KiB
random_01.txt AC 5 ms 3556 KiB
random_02.txt AC 5 ms 3608 KiB
random_03.txt AC 6 ms 3576 KiB
random_04.txt AC 6 ms 3508 KiB
random_05.txt AC 4 ms 3496 KiB
random_06.txt AC 4 ms 3548 KiB
random_07.txt AC 4 ms 3552 KiB
random_08.txt AC 4 ms 3616 KiB
random_09.txt AC 3 ms 3628 KiB
random_10.txt AC 1 ms 3548 KiB
random_11.txt AC 1 ms 3612 KiB
random_12.txt AC 2 ms 3568 KiB
random_13.txt AC 1 ms 3564 KiB
random_14.txt AC 2 ms 3588 KiB
random_15.txt AC 3 ms 3524 KiB
random_16.txt AC 3 ms 3588 KiB
random_17.txt AC 4 ms 3624 KiB
random_18.txt AC 2 ms 3532 KiB
random_19.txt AC 16 ms 3556 KiB
random_20.txt AC 9 ms 3568 KiB
random_21.txt AC 3 ms 3604 KiB
random_22.txt AC 21 ms 3600 KiB
random_23.txt AC 19 ms 3716 KiB
random_24.txt AC 30 ms 3604 KiB
sample_01.txt AC 1 ms 3516 KiB
sample_02.txt AC 1 ms 3516 KiB
sample_03.txt AC 1 ms 3620 KiB
wide_00.txt AC 266 ms 3596 KiB