摘要: dp[i][j][k]表示从i到j合并,能否合并成字母k。。怎么暴力怎么来转移~View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 #include <algorithm> 6 #include <vector> 7 8 #define N 222 9 10 using namespace std;11 12 const char t[5]={' ','W 阅读全文
posted @ 2013-03-12 23:59 proverbs 阅读(738) 评论(0) 推荐(0) 编辑
摘要: 双向bfs。尼玛,比单向都慢。。。抑郁。。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <algorithm> 5 #include <cstdio> 6 7 #define N 77777 8 #define INF 0x3f3f3f3f 9 10 using namespace std;11 12 int n,st,ed;13 int map[5][5];14 int q[2][N];15 int sp[2] 阅读全文
posted @ 2013-03-12 23:57 proverbs 阅读(552) 评论(0) 推荐(0) 编辑
摘要: 爆搜啊~利用约数个数公式求答案。相当于找约数最多的数,个数相同取较小的。有一点需要注意:分解质因数,较小的数的指数一定大于等于较大的数的指数(显然的么~要么把大的数换成小的一定更优~)这样一来,可以确定质因数最多十个,剩下就是暴力了~View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 #include <algorithm> 6 7 using namespace std; 8 9 long lo 阅读全文
posted @ 2013-03-12 23:55 proverbs 阅读(1117) 评论(0) 推荐(0) 编辑
摘要: 想到了一部分,没想全,还是看了题解。。也不知道为什么对。。。首先,求出所有点的4个边界值形成的一个矩形,第一个正方形的一个边界一定与这个矩形的4个角中的一个重合,枚举4次即可,然后再找到剩下的点中的边界,重复一遍上面的操作,最后判断一下一个正方形是否可以覆盖剩余的所有矩形View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <algorithm> 5 #include <cstring> 6 7 #define N 222 阅读全文
posted @ 2013-03-12 23:51 proverbs 阅读(987) 评论(0) 推荐(0) 编辑
摘要: 按照关系建立又向边,缩点为DAG图,重新构图,判断是否有且仅有一个出度为0的点,如果是,这个点所代表的环上的点数就是答案。否侧,不存在~View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <cstdlib> 5 #include <algorithm> 6 7 #define N 111111 8 #define M 555555 9 10 using namespace std;11 12 struct S13 {14 阅读全文
posted @ 2013-03-12 23:49 proverbs 阅读(412) 评论(0) 推荐(0) 编辑
摘要: 第一问:最长xx子序列第二问:f[i]表示前i个的最少花费,可以从满足条件j(假设以a[i]结尾的最长xx组序列长度为len,则j需要满足以a[j]结尾的最长xx组序列长度为len-1)方法:记录最长xx子序列的转移,邻接表存,然后枚举每个转移。ps:有个结论:如果从j转移到i的话,那么中间一定有一个k(k>=j&&k<i),使得j~k的高度都是a[j],k+1~i的高度都是i,且这样的花费是最优的,很容易想明白的~这个暴力显然tle,怎么可能会ac?数据弱,不解释View Code 1 #include <iostream> 2 #include &l 阅读全文
posted @ 2013-03-12 23:46 proverbs 阅读(1714) 评论(0) 推荐(0) 编辑
摘要: 不知道什么印象,好像以前见过,记得要把数列倒过来的~nlogn的最长上升子序列。但是方案不好搞~PS:看好是谁的字典序最小。。。换个问题,假设知道以a[i]为开头的最长下降子序列的长度,是不是就好搞了?方法是从左往右,直接贪心的选这个i(以a[i]为开头的最长下降子序列的长度要大于你需要的长度)一定是能使字典序最小~前面说了,倒过来做就行了, 因为我们只会求以a[i]结尾的最长上升子序列的长度。。。View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #inclu 阅读全文
posted @ 2013-03-12 23:37 proverbs 阅读(1010) 评论(0) 推荐(0) 编辑
摘要: 第一问,明显的二分答案+验证。第二问,dp[i][j]表示前j段切i刀的满足第一问的方案数,然后dp[i][j]=sigma(dp[i-1][k]) (k满足第一问限制)显然在循环j的时候是可以算出来这个值的,所以总复杂度是n*m的。其实我一开始写的是dp[i][j]表示前i个切j刀的方案数,显然这样写不能优化。。。然后写出方程,发现调换i、j就可以了~View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdlib> 4 #include <cstdio> 5 #i 阅读全文
posted @ 2013-03-12 23:30 proverbs 阅读(694) 评论(0) 推荐(0) 编辑
摘要: 为按照极角,转化为线段覆盖问题。这题有个特别混蛋的trick,就是后掉落的把先掉落的完全覆盖了,我就没考虑这个,无限wa啊!!View Code 1 #include <iostream> 2 #include <cstring> 3 #include <cstdio> 4 #include <algorithm> 5 #include <cstdlib> 6 #include <cmath> 7 #include <vector> 8 9 #define N 1111 10 #define PI 3.1415 阅读全文
posted @ 2013-03-12 23:14 proverbs 阅读(404) 评论(0) 推荐(0) 编辑
摘要: 这个题我总是想用循环完成转移,最后发现,还是手工枚举最靠谱~建立线段树,线段树的每个节点(代表的是区间)维护以上六个值,true表示连通,false表示不连通,具体可以看我的代码~View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <algorithm> 6 7 #define N 111111 8 9 using namespace std; 10 11 struct DAT 阅读全文
posted @ 2013-03-12 23:10 proverbs 阅读(1526) 评论(2) 推荐(1) 编辑