您的位置:首页 > 其它

URAL 1210 Kind Spirits

2011-08-12 14:45 267 查看
182955	ylwh	URAL 1210	Accepted	108 KB	31 ms	C	712 B	2011-08-12 14:39:20
#include <stdio.h>
#include <string.h>
#define N 31
#define MAX 200000000
int main()
{
int n, temp
, s
, i, j, k, pre, dis, ans;
char ch;
while(scanf("%d", &n) != EOF)
{
s[0] = 1;
s[1] = 0;
for(i=1; i<=n; i++)
{
scanf("%d", &k);
temp[0] = k;
for(j=1; j<=k; j++)
temp[j] = MAX;
for(j=1; j<=k; j++)
{
while( scanf("%d", &pre), pre)
{
scanf("%d", &dis);
if(temp[j] > s[pre] + dis)
temp[j] = s[pre] + dis;
}
}
if(i!=n) scanf(" %c", &ch);
for(j=0; j<=temp[0]; j++)
s[j] = temp[j];

}
ans = s[1];
for(i=2; i<=s[0]; i++)
if(s[i] < ans)
ans = s[i];
printf("%d\n", ans);
}
return 0;
}
睡了一觉~~,想出来了~~~(话说刚开始想的是最短路。。。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  c