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; }睡了一觉~~,想出来了~~~(话说刚开始想的是最短路。。。
相关文章推荐
- URAL 1210 Kind Spirits (DP动态规划)
- ural Kind Spirits 最短路径、dp
- Ural 1210
- URAL 1091 Tmutarakan Exams (DP或容斥)
- Ural——1297Palindrome(Manacher)
- Object-C之动态类型(isKindOfClass, isMemberOfClass,id)等
- Another kind of Fibonacci
- hdu3306 - Another kind of Fibonacci
- Another kind of Fibonacci(hdu3306)矩阵快速幂
- URAL1004 Sightseeing Trip Floyd 最小环
- Ural 1635. Mnemonics and Palindromes
- Ural 2038 Minimum Vertex Cover(二分图最小顶点覆盖+快速读入)
- URAL 1325--Dirt
- Objective-C语法之动态类型(isKindOfClass, isMemberOfClass,id)等
- URAL 2067 Friends and Berries (推理,数学)
- URAL 2089 Experienced coach Twosat
- URAL 1025 Democracy in Danger 贪心
- BZOJ3346 : Ural1811 Dual Sim Phone
- ural 1110,快速幂
- ural 1356. Something Easier 哥德巴赫猜想