Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:弱弱贴一个时间空间长度都还好的代码 47ms 160k 386BIn 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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator