摘要: 1 =============================以下是最小生成树+并查集====================================== 2 【HDU】 3 1213 How Many Tables 基础并查集★ 4 1272 小希的迷宫 基础并查集★ 5 1325&&poj1308 Is It A Tree? 基础并查集★ 6 1856 More is better 基础并查集★ 7 1102 ... 阅读全文
posted @ 2013-07-22 10:04 LJ_COME!!!!! 阅读(1312) 评论(0) 推荐(1) 编辑
摘要: 1.burnside定理,polya计数法这个大家可以看brudildi的《组合数学》,那本书的这一章写的很详细也很容易理解。最好能完全看懂了,理解了再去做题,不要只记个公式。*简单题:(直接用套公式就可以了)pku2409 Let it Beadhttp://acm.pku.edu.cn/JudgeOnline/problem?id=2409pku2154 Colorhttp://acm.pku.edu.cn/JudgeOnline/problem?id=2154pku1286 Necklace of Beadshttp://acm.pku.edu.cn/JudgeOnline/probl. 阅读全文
posted @ 2013-04-19 21:29 LJ_COME!!!!! 阅读(191) 评论(0) 推荐(0) 编辑
摘要: LICS的应用。还是从最后的结果考虑,肯定是在某个位置的i左边(包括i)递增的序列,右边(包括i)相应的对称的递减的序列,这个序列肯定是,1--i和i--n的逆序的公共递增序列,而1--i和i--n的逆序的公共递增序列肯定是一个符合题意的选择,那么以i为分界点的最优解肯定就是1--i和i--n的逆序的最长公递增序列。然后枚举位置i取以i为分界点的最优解的最大解就可以了。先按这个思路A了,有很多无用的循环,又优化了下。 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #in... 阅读全文
posted @ 2013-08-04 23:56 LJ_COME!!!!! 阅读(228) 评论(0) 推荐(0) 编辑
摘要: 看了http://wenku.baidu.com/view/3e78f223aaea998fcc220ea0.html 1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #define LL long long10 using namespace std;11 const int inf=0x3f3f3f3f;12 const int maxn=500+10;13 int a[maxn],b[maxn],f[maxn]; 14 int main... 阅读全文
posted @ 2013-08-04 14:56 LJ_COME!!!!! 阅读(111) 评论(0) 推荐(0) 编辑
摘要: Dijkstra最短路模拟每个key的坠落时间,发现就是Dijkstra。求出每个key的时间求其最大值,再求每条边整个坠落的时间,求其最大值,得二者最大值即结果。其中每条边的坠落事件为tv+(cost-(tv-tu))/2,其中u,v为边的两个key节点,tv>tu,cost为边的权值 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 const int maxn=500+10; 7 const int inf=0x3f3f3f3f; 8 const int maxm=maxn*maxn; 9 s. 阅读全文
posted @ 2013-07-19 16:58 LJ_COME!!!!! 阅读(189) 评论(0) 推荐(0) 编辑
摘要: 二着色+DP在不是互相认识的节点之间连一条边,最后得到由多个连通分量构成的图。把图中节点分为两组,保证图中每条边的两个顶点不能再同一组。对每个连通分量进行二着色,每个连通分量的点就分为了a,b两组。假定最后整个图分为1,2两组。每个连通分量的a,b两组,无非一个在1组一个在2组,通过DP,确定每个连通分量中a,b哪个在1组,哪个在2组时最有。然后就是DP的过程,没想出来,看了其他人的结题报告。f[i][j]表示对于前i个联通分量,是否可达到第1组和第2组的差值为j的状态。设a为连通分量i的两组的差值则f[i][j]=1当f[i-1][j-a]==1||f[i-1][j+a]==1。 1 #i. 阅读全文
posted @ 2013-06-28 17:20 LJ_COME!!!!! 阅读(276) 评论(0) 推荐(0) 编辑
摘要: 二分图匹配+floyd求图中节点是否可达。模型很容易想到。此题我认为用网络流最好解释,如果有device有重复的话。二分图建模比较麻烦。一开始没想到这点,用二分图做的,但是AC了,数据应该没有device重复的情况。然后就是判断一个插头通过适配器能转化成什么其他的插头,刚开始用矩阵乘法来判断这个关系,数据一开到500运行时就运行错误(感觉也不是很大啊,至今还不知道原因),后来在网上发现有用floyd做,想了想,确实可以,而且还简单,就是个DP的过程。 1 #include 2 #include 3 #include 4 #include 5 #i... 阅读全文
posted @ 2013-06-22 20:33 LJ_COME!!!!! 阅读(264) 评论(0) 推荐(0) 编辑
摘要: 拓扑排序,做的时候wa了n次,后来找来数据,又想了想,发现了自己的错误,就是当拓扑排序的时候出现了不确定的情况,还要在拓扑下去,因为可能还会有矛盾的情况出现,保证没矛盾的情况下才可以说是不确定的情况 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 using namespace std; 6 const int maxn=30; 7 int e[maxn*maxn],head[maxn],next[maxn*maxn],in[m 阅读全文
posted @ 2013-06-20 16:04 LJ_COME!!!!! 阅读(149) 评论(0) 推荐(0) 编辑
摘要: DP+简单优化,状态转移方程容易看出,优化看了http://hi.baidu.com/forverlin1204/blog/item/df9c62dc0fb16bd38d1029d8.html。哎,太粗心了,初始化时忘了得平方,看了1个多小时才发现 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 const int inf=2000000000; 6 const int maxn=100000+10; 7 int f[100+10] 阅读全文
posted @ 2013-06-11 13:44 LJ_COME!!!!! 阅读(175) 评论(0) 推荐(0) 编辑
摘要: 状态转移方程还是很容易想出的,但是n的限值1000不知道为什么 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 const int maxn=100+10; 6 double f[2][maxn]; 7 int c; 8 int n,m; 9 int main()10 {11 while(scanf("%d",&c)&&c)12 {13 scanf("%d%d",&am 阅读全文
posted @ 2013-06-10 15:47 LJ_COME!!!!! 阅读(123) 评论(0) 推荐(0) 编辑
摘要: 状态压缩DP基础题 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 const int maxn=15; 6 const int mod=100000000; 7 int num[maxn],s[200]; 8 int f[maxn][200],amoun[1<<13]; 9 int main()10 {11 //freopen("1.txt","r",stdin);12 int 阅读全文
posted @ 2013-06-09 13:34 LJ_COME!!!!! 阅读(114) 评论(0) 推荐(0) 编辑