Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:弱弱贴一个时间空间长度都还好的代码 47ms 160k 386B

Posted by jakeclown at 2019-04-22 21:32:46 on Problem 2387
In Reply To:弱弱贴一个时间空间长度都还好的代码 47ms 160k 386B Posted by:416221843 at 2017-07-04 15:18:08
> #include<cstdio>
> #define min(a,b) a<b?a:b
> int n, m, d[1005], i, j, x[2002], y[2002], z[2002];
> int main()
> {
> 	scanf("%d%d", &m, &n);
> 	for (i = 0; i < m; i++)		scanf("%d%d%d", x + i, y + i, z + i);
> 	for (i = 2; i <= n; i++)    d[i] = 1 << 20;
> 	while (i--)
> 		for (j = 0; j < m; j++)
> 			d[x[j]] = min(d[x[j]], d[y[j]] + z[j]), d[y[j]] = min(d[x[j]] + z[j], d[y[j]]);
> 	printf("%d\n", d[n]);
> }

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator