容易想到将问题转化为求图的独立数问题 ,但求一般图的独立集是一个NPC问题,需要一些转化. 状态压缩,枚举每个上古农场是否选择,然后将剩下的新农场根据i + j奇偶性分为x , y集. 结果为 max(tot  + nx + ny - 二分图匹配数) #include<cstdio> #include<iostream> #include<cstdlib> #include<cstring> #include<string> #include&l…
当初合肥区域赛的题(现场赛改了数据范围就暴力过了),可惜当初后缀数组算法的名字都没听过,现在重做下. i从1到n - 1,每次枚举rank[i]附近的排名,并记录当起点小于i时的LCP(rank[i], d)的最大值,或是在LCP不变时更新起点. #include<cstdio> #include<iostream> #include<algorithm> #include<cstring> #include<cstdlib> using nam…
我对于题目的一种理解 改造农场 1.建新农场 在空的点选 2.重建旧农场 选一个点属于这个农场的地方都要选 最后的农场都不能相连 所以枚举旧农场的个数并进行二分图匹配 #include<bits/stdc++.h> using namespace std; int N,M; char mp[12][12]; vector<pair<int,int> > farm[12]; int has[12]; int dir[5][5] = { {1,0}, {0,1}, {-1,…
Wei Qing (died 106 BC) was a military general of the Western Han dynasty whose campaigns against the Xiongnu earned him great acclaim. He was a relative of Emperor Wu because he was the younger half-brother of Empress Wei Zifu (Emperor Wu’s wife) and…
Travel Time Limit: 1500/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 2404    Accepted Submission(s): 842 Problem Description Jack likes to travel around the world, but he doesn’t like to wait. Now, he is tr…
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5493 题目大意,t组数据,n个人,n行每行分别是人的身高和这个人的左边或右边比他高的人的个数,输出符合条件的字典序最小的人排列的序列. 想到线段树就很好做了,记录空位,按顺序安放人的身高,和原来做的题目很相似 #include<cstdio> #include<algorithm> using namespace std; struct point { int h,k; bool oper…
题目;http://acm.hdu.edu.cn/showproblem.php?pid=5491 题意就是,T组测试数据.然后L,S1,S2.L的二进制中有x个1,x满足  S1<=x<=S2 求满足S1<=x<=S2 直接暴力,但是有个地方要注意,当L在递增枚举的过程中,X小于S1的时候,将其二进制中S1-X个0位转化成1,不然会超时 #include<cstdio> using namespace std; typedef long long ll; int ma…
题意  给定n个点,任意两点之间可以不连边也可以连边.如果连边的话可以染上m种颜色. 求最后形成的图,是一个带环连通图的方案数. 首先答案是n个点的图减去n个点能形成的树. n个点能形成的树的方案数比较好求,根据prufer序列可以知道n个点形成的无根树的个数为$n^{n-2}$ 那么现在问题变成求n个点形成的连通图的个数. 图有连通和不连通的,那么就是图的总数减去不连通的图的总数. 图的总数很简单,$m^{\frac{n(n-1)}{2}}$,那么现在要求不连通的图的总数. 设$f(n)$为$…
Problem Description As we know, sequence in the form of an=a1+(n−1)d is called arithmetic progression and sequence in the form of bn=b1qn−1(q>1,b1≠0) is called geometric progression. Huazheng wants to use these two simple sequences to generate a simp…
HDU 5489 Removed Interval 题意: 求序列中切掉连续的L长度后的最长上升序列 思路: 从前到后求一遍LIS,从后往前求一遍LDS,然后枚举切开的位置i,用线段树维护区间最大值,在i~n中找到第一个比a[i - L]大的位置k,用LIS[i - L] + LDS[k]更新答案. 代码 #include <iostream> #include <cstdio> #include <fstream> #include <algorithm>…