自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(20)
  • 收藏
  • 关注

原创 HDU 4705 Y (树形DP)

思路:反面考虑,用总的方案数减去A,B,C三点在同一路径上的方案数。于是我们可以确定中间点B,在当前以B为根求得的son中任选一个,在剩下的节点n-tmp-1(tmp为已经求得的B的儿子的个数)中任选一个,产生tmp*(n-tmp-1)中组合。//#pragma comment(linker, "/STACK:102400000,102400000")#pragma comment(link

2015-08-20 19:55:29 316

原创 HDU 1814 Peaceful Commission (2-SAT)

矛盾的情况为:存在Ai,使得Ai既必须被选又不可选。 枚举每一对尚未确定的Ai, Ai‘ ,任选1个,推导出相关的组,若不矛盾,则可选择;否则选另1个,同样推导。若矛盾,问题必定无解。此算法正确性简要说明:由于Ai,Ai '  都是尚未确定的,它们不与之前的组相关联,前面的选择不会影响Ai, Ai '  。算法的时间复杂度在最坏的情况下为O(nm)。在这个算法中,并

2015-08-19 15:03:34 442

原创 HDU 3342 Legal or Not (拓扑排序)

拓扑排序应用,判断是否有环,,//#pragma comment(linker, "/STACK:102400000,102400000")#include #include #include #include #include using namespace std;typedef long long LL;const long long mod = 1e9 + 7;con

2015-08-18 09:59:49 316

原创 HDU 1285 确定比赛名次 (拓扑排序)

基础题,不多说。。//#pragma comment(linker, "/STACK:102400000,102400000")#include #include #include #include #include using namespace std;typedef long long LL;const long long mod = 1e9 + 7;const int

2015-08-18 09:51:27 290

原创 POJ 3020 Antenna Placement (Hungary)

求最小覆盖边, 无向二分图的最小路径覆盖 = 顶点数 – 最大二分匹配数/2 由于构图过程中匹配双向的,所以匹配数多了一倍,最后要/2 构图可以用奇偶,或者用数来标记//#pragma comment(linker, "/STACK:102400000,102400000")#include #include #include #include #include usi

2015-08-15 10:08:30 426

原创 HDU 2853 Assignment (KM算法)

来自网上的巧妙思路:因为我们要变动最小,所以对在原计划中的边要有一些特殊照顾,使得最优匹配时,尽量优先使用原计划的边,这样变化才能是最小的且不会影响原匹配。根据这个思想,我们可以把每条边的权值扩大k倍,k要大于n。然后对原计划的边都+1。精华全在这里。我们来详细说明一下。全部边都扩大了k倍,而且k比n大,这样,我们求出的最优匹配就是k倍的最大权值,只要除以k就可以得到最大权值。实现原计

2015-08-13 22:16:21 359

原创 HDU 2255 奔小康赚大钱 (KM算法)

直接输入w[i][j]边权值建图套模板就可以了 //#pragma comment(linker, "/STACK:102400000,102400000")#include #include #include #include #include using namespace std;typedef long long LL;const long long mod = 1e9

2015-08-12 20:20:16 339

原创 HDU 5379 Mahjong tree (DFS)

#pragma comment(linker, "/STACK:102400000,102400000")#include #include #include #include #include using namespace std;typedef long long LL;const long long mod = 1e9+7;const int inf = 0x3f3f3f

2015-08-12 13:39:41 278

原创 HDU 5373 The shortest problem (水题)

~~水题,,,#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;const int inf = 0x3f3f3f3f;typedef lon

2015-08-11 19:47:48 329

原创 HDU 5371 Hotaru's problem (Manacher+暴力)

#include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std;const int inf = 0x3f3f3f3f;typedef long long LL;

2015-08-11 18:10:25 474 1

原创 HDU 4634 Swipe Bo (BFS+状压)

哎,学到了~!@~!@//#pragma comment(linker, "/STACK:102400000,102400000")#include#include#include#include#include#include#includeusing namespace std;const int M = 60005;const int INF = 1e10;//

2015-08-09 18:43:45 594

原创 HDU 5237 Base64 (Java大法好)

~!#~#@~!@~~~import java.util.Base64;import java.util.Scanner;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int casee = 0; int t = sc.nex

2015-08-09 17:00:55 572

原创 HDU 4666 Hyperspace(最长曼哈顿距离)

POJ 2926加强版,使用set处理,,//#pragma comment(linker, "/STACK:102400000,102400000")#include#include#include#includeusing namespace std;const int M= 60005;#define inf 1e100int a[M][5];int n,dem

2015-08-07 15:15:07 564

原创 POJ 2926 Requirements (多维最远曼哈顿距离)

考虑二维空间上两个坐标之间的曼哈顿距离(x1, y1) 和 (x2, y2),|x1-x2| +|y1-y2|去掉绝对值符号后共有下列四种情况(x1-x2) + (y1-y2), (x1-x2) + (y2-y1), (x2-x1) + (y1-y2), (x2-x1) + (y2-y1)转化一下:(x1+y1) - (x2+y2), (x1-y1) - (x2

2015-08-07 13:55:09 727

原创 后缀表达式计算

将中缀表达式转换为后缀表达式:与转换为前缀表达式相似,遵循以下步骤:(1) 初始化两个栈:运算符栈S1和储存中间结果的栈S2;(2) 从左至右扫描中缀表达式;(3) 遇到操作数时,将其压入S2;(4) 遇到运算符时,比较其与S1栈顶运算符的优先级:(4-1) 如果S1为空,或栈顶运算符为左括号“(”,则直接将此运算符入栈;(4-2) 否则,若优先级比栈顶运算符的高,也将

2015-08-05 21:04:50 482

原创 HDU 1063 Exponentiation (高精度)

JAVA大法好~~import java.util.Scanner;import java.math.BigInteger;import java.math.BigDecimal;public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); i

2015-08-05 11:57:50 389

原创 HDU 5351 MZL's Border(找规律)

由于有高精度,用JAVA写。。。第一次写正规的JAVA,哭晕import java.util.Scanner;import java.math.BigInteger;public class Main{ public static void main(String[] args){ Scanner sc = new Scanner(System.in);

2015-08-04 18:08:25 717

原创 HDU 3473 Minimum Sum (划分树)

查询某区间的中位数与区间所有值的差值和//#include #include #include #include #include using namespace std;typedef long long LL;const int MAXN = 200010;int tree[20][MAXN];//表示每层每个位置的值int sorted[MAXN];//已经排序好的数

2015-08-04 09:55:32 310

原创 POJ 2104 K-th Number (主席树 || 划分树)

静态区间查询第K大   主席树入门//#include #include #include #include #include using namespace std;const int MAXN = 100010;const int M = MAXN * 30;int n,q,m,tot;int a[MAXN], t[MAXN];int T[M], lson[M], r

2015-08-03 13:55:46 277

原创 HDU 2852 KiKi's K-Number(树状数组+二分)

0的时候增加元素 1的时候删除 2的时候查找第几个比当前数大的//#include #include #include #include #include using namespace std;const int M = 100005;int N;int d[100005];int s[100005];int flag;int s1[100005];int lo

2015-08-02 18:26:08 304

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除