摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=123这题本来交上去就超时了, 然后自己就囧了.... 不知道该用什么更高级的结构了...然后去百度的题解....看到的是和我一样的思路, 但怎么就过了呢.. 仔细看了下, 别人的更新都是从当前点更新到0位置.然而我是从当前点, 更新到数组的结尾, 结果就不行了.然后自己改了下代码就过了......感觉是数据出的问题,偏向了某一边把....用线段树是不是会更好呢?View Code 1 #include <iostream> 2 #include <stdio.h> 3 # 阅读全文
posted @ 2012-09-04 22:24 YORU 阅读(251) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=116和 士兵杀敌(一) 是一样的。View Code 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 const int maxn = 1000005; 5 int ans[maxn], n; 6 int lowbit(int x) 7 { 8 return x & (-x); 9 }10 11 int getSum(int x)12 {13 int i, sum=0;14 f 阅读全文
posted @ 2012-09-04 21:34 YORU 阅读(134) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=108线段树,或者树状数组View Code 1 #include <iostream> 2 #include <stdio.h> 3 using namespace std; 4 const int maxn = 1000005; 5 int ans[maxn], n; 6 int lowbit(int x) 7 { 8 return x & (-x); 9 }10 11 int getSum(int x)12 {13 int i, sum=0;14 for(i 阅读全文
posted @ 2012-09-04 21:14 YORU 阅读(151) 评论(0) 推荐(0)
摘要: http://acm.nyist.net/JudgeOnline/problem.php?pid=36今天突然想到那天文哥给我看的最长公共子序列的问题....然后自己找了这道题来看看..那天文哥叫我看的时候, 自己就这么一下扫过去. 没什么概念.今天自己从头按照它的分析方法来分析了下.f[i][j] 表示 s1 的 i 个字符和 s2 的 j 个字符内最长的公共子序列if(s1[i] == s2[j]) f[i][j] = f[i-1][j-1] + 1;else f[i][j] = max(f[i-1][j], f[i][j-1]); 当不相同的时候,则考虑在 s1 的 i 个字符和 s.. 阅读全文
posted @ 2012-09-04 16:03 YORU 阅读(370) 评论(0) 推荐(0)