- 博客(583)
- 收藏
- 关注
原创 线段树整理
开始PHD生涯,好久不做题了,手生的不行,代码能力、算法能力直线下滑。 不管以后我做什么方向,做做题目能很好地锻炼我的思维,所以以后开始继续做题,纯粹为了玩! 先整理一下线段树方面的题目吧,最近项目有用到。
2013-09-28 20:18:04
2024
原创 zoj 3583 Simple Path
自从区域赛以后就没参加浙大月赛这种比赛了 这题比赛的时候也没有过 有两种解法,这种是并查集 想象一下从s到t的一条简单路,想想简单路上每个点的性质:比如简单路上的点i,不管删去图上任何一个点,点i总会至少与s或t在一个相连的集合中 另外想想不在简单路上的点j,一定可以找到一个点,使得j与s和t都不在一个相连的集合中 用这种性质即可证明 #include #include c
2012-03-13 19:51:11
1805
2
原创 HDU 4107
线段树的题目 #include #define LL(x) x << 1 #define RR(x) x << 1 | 1 const int MAXN = 200000 + 123; struct NODE { int l, r, rmax, rmin; int lazy; int mid() { return (l + r) >> 1;
2012-02-25 19:35:40
1361
原创 Codeforces Beta Round #75 Igloo Skyscraper
很不错的一道线段树的题目 在每个节点里面加个线性表,这是关键的操作! 线性表里面是这个节点的范围内,将它按照a数组从小到大排序,接着剔除掉a[i] >= a[j] 并且b[i] >= b[j]这种j 另外还要用到(a[x] - a[y])*(b[z]-b[y
2011-10-02 11:28:13
1145
原创 SPOJ 1793. Text Generater II
AC自动机+矩阵乘法+容斥原理 刚开始是用单纯的状态压缩,当然是TLE 后来用容斥原理,接着几乎快了64倍还多,接着各种弄,就过了 2.99S,不知道那些弄到0.05秒的神牛怎么弄的
2011-10-01 19:43:39
1186
原创 hdu 3442 Three Kingdoms
状态压缩+BFS //记忆话搜索 #include #include #include using namespace std; char map[55][55]; int mp[55][55]; int dp[55][55][1 int dx[4]
2011-09-09 11:39:26
1222
原创 zoj 1015 Fishing Net//弦图的判定
整理一下乱七八糟的知识点 #include #include using namespace std; const int maxn = 1010; const int inf = 100000000; struct EDGE { int v, next; }e
2011-09-07 10:56:16
1882
原创 hdu 3666 THE MATRIX PROBLEM //2010哈尔滨现场赛
差分约束,不是很难看出来 不过需要一下流氓剪枝。。。。 #include #include #include #include using namespace std; #define swap(t,a,b) (t=a,a=b,b=t) const int E=4
2011-09-07 10:13:53
1120
原创 poj 1222 EXTENDED LIGHTS OUT //高斯消元
整理一下这块而已 #include #include #include #include #include using namespace std; #define MAX_VAR 110 //geshu #define MAX_EQU 110 //位数 #define M
2011-09-06 19:49:53
1225
原创 hdu 3584 Cube //三维树状数组
由二维的推一下就好了 注意一下三维空间的容斥性,更新的时候 注意一下这是区间更新,单点查询 仔细想一想为什么可以这么做 Add(x1, y1, z1, 1); Add(x2+1, y1,
2011-09-06 11:23:04
1021
原创 hdu 3592 World Exhibition //差分约束
刷刷水题,莫笑莫笑 #include #include #include using namespace std; #define swap(t,a,b) (t=a,a=b,b=t) const int E=20002; const int V=1001; con
2011-09-06 10:45:56
1115
原创 hdu 3517 Adopt or not
很明显就是求最大独立集,求什么就用什么当两边 主要是找最大独立集的必须点 首先是如果一个点没有匹配过,那么删除这个点,对匹配数无影响,所以一定是独立集中的 接着对匹配中的点,某些点也一定是独立集中 辨别的方法是,比如A和B匹配,如果A不去匹配B,而
2011-09-06 10:43:39
2339
原创 hdu 4008 Parent and son
/* 首先以1为根,扫描一遍树,得到每个节点的minchild[i][2],儿子节点的最小值和次小值(不同子树的) 和每个节点的最小后缀的值mindown[i] (1)如果x是y的父节点的话,那么直接输出mindown[i],minchild[i][0]即可 (2)如果y是x的父
2011-09-05 16:25:32
3277
原创 hdu 4003 Find Metal Mineral
#include #include int n, s, k; const int MAXN = 10010; struct EDGE { int v, next, w; }edge[MAXN * 2]; int head[MAXN]; int cnt; int dp[MAXN][11]; void addedge(int u, int v, int val) { edge[cn
2011-09-04 19:59:17
1105
原创 hdu 4009 Transfer water
#include #include #define SIZE 1100 #define TYPE int struct point { int x, y, z; }node[1010]; struct Edge { int f,t; TYPE cost;
2011-09-04 15:29:53
921
原创 最小树形图
poj 3164 Command Network #include #include #include #include using namespace std; #define maxn 120 #define INF 99999999999.0 int n,m;
2011-09-04 10:28:13
765
原创 hdu 3338 Kakuro Extension
最大独立集 #include #include int usedif[1005]; int link[1005]; int mat[1005][1005]; long long a[1010]; int gx, gy; bool can(int t) { for(
2011-09-02 20:03:23
1302
原创 hdu 3991 Harry Potter and the Present II //最小路径覆盖
很容易看出是最小路径覆盖 那场比赛几乎没怎么做,弄项目了 接着注意一些比较白痴的问题,比如将数组赋值为1 #include #include struct EDGE { int v, next; }edge[2010010]; struct NODE {
2011-09-02 12:33:20
1149
原创 hdu 3987 Harry Potter and the Forbidden Forest//边数最小的最小割 2种解题方法
每条边的权值改为w*(M+1)+1 最后得到的和sum sum div (M+1) 得到的是最小割的值,用(M+1)是为了不被后面的1影响到 sum mod (M+1)得到的是最小割的边数,这个是在上面的最小割前提下求出来的(YY一下,在原题中可能存在多组割边,边数不同,
2011-09-02 11:02:52
1177
原创 hdu 4000 Fruit Ninja
小大中+小中大= ? #include #include const int MAXN = 100000 + 1234; const int mod = 100000007; int n; long long tree[MAXN]; long long ans[MAXN
2011-09-01 20:50:02
1147
原创 hdu 3333 Turing Tree
按右端点排序 #include #include #include using namespace std; const int MAXN = 50010; const int MAXM = 200000 + 123; struct Edge { int id,
2011-08-29 22:32:12
958
原创 hdu 3478 //判联通+二分图判定
#include #include const int N = 100010; struct NODE { int v, next; }edge[510000 * 2]; int clr[N], n, m; int head[N], e; void addedge(int
2011-08-29 19:40:41
1057
原创 hdu 3625 Examining the Rooms //组合数学DP
做的十分顺利,1Y #include #include long long dp[21][21]; double ans[21][21]; double out[21][21]; long long sum = 0; int main() { memset(
2011-08-29 16:19:19
1343
原创 hdu 3627 Giant For //线段树
首先以x为第一关键字,y为第二关键字进行排序,离散化 得到一个长度为num的数组(任何一次查询对应的点都能在这个数组中找到) 对此进行建树 比如进行第i次操作 找到其在数组中对应的点pos 那么pos--->num这里面的所有点的x值都大于等于pos点 看这一段序列是
2011-08-29 15:37:43
1093
原创 zju 3526 Weekend Party
每次浙大月赛都打酱油,中午这种题,愣是把数字敲错了。 。。。。。。 #include #include int num[10]; char s[20], s2[10]; int t[10]; int main() { int n; whil
2011-08-28 22:36:13
694
原创 hdu 3030 Increasing Speed Limits
就是在一个500000的串里找除上升子序列的个数 还是比较容易想到DP转移方程的 dp[i] = sum(dp[j]|j dp[i]就是说以i结尾的上升子序列的个数 现在是平方级的算法 找一个上升子序列,很容易想到是树状数组 注意一下离
2011-08-27 11:12:11
1117
原创 zoj 3344 //组合数学那种的DP
import java.io.*; import java.math.*; import java.util.*; /** * * @author acm */ public class Main { public static void main(String[]
2011-08-26 20:21:25
1889
原创 反思
听了ZZC师兄的分析,还是感觉要反思一番 是否真的过于注重实现而没有注重思维的转化? 跟真正强队的区别为什么永远追不上? 训练方法肯定有问题 做的题目也过于陈旧 反思吧。
2011-08-22 19:05:10
1127
2
原创 zoj 3471 Most Powerful //状态压缩DP
#include #include #include using namespace std; const int N = (1 << 10); int map[11][11]; int dp[N]; int main() { int n; while(sc
2011-08-18 20:47:48
744
原创 hdu 3001 Travelling//状态压缩DP
#include #include #include using namespace std; const int inf = 100000000; int tri[12] = {0,1,3,9,27,81,243,729,2187,6561,19683,59049}; i
2011-08-18 19:58:43
925
原创 POJ 3311 Hie with the Pie //状态压缩DP
TSP,可以用状态压缩做,记得先用FLOYED处理 #include #include #include using namespace std; int n; int map[12][12]; int dp[(1 << 11) - 1][11]; int mai
2011-08-16 19:59:46
833
原创 hdu 3943 K-th Nya Number
#include #include #include #include #include using namespace std; long long f[20][21][21][10]={0}; int i,j,k,l,e; long long tens[21];
2011-08-16 18:56:42
1205
原创 poj 1185 炮兵阵地 //状态压缩DP
注意只有一行等这些特殊情况 这种状态压缩DP还是比较简单的,这个题是前2行推出下一行的状态 #include #include #include using namespace std; const int MAXN = (1 << 10); int n
2011-08-15 21:24:52
643
原创 poj 3254 Corn Fields //状态压缩DP
#include #include const int MAXN = (1 << 12) - 1; const int MOD = 100000000; int n, m; int state[12][MAXN]; int dp[2][MAXN]; void get_stat
2011-08-15 18:57:07
593
原创 hdu 3689 Infinite monkey theorem
去年杭州区域赛的一道题目,比较简单的AC自动机 #include #include const int NODE = 1000; const int CH = 26; int tree[NODE][CH], cnt; int fail[NODE], word[NOD
2011-08-15 17:56:57
1366
原创 hdu 3586 Information Disturbing 二分+树状DP
这种题目很容易看出二分,接着就是O(N)的验证了 #include #include #include using namespace std; const int N = 1000 + 12; const int inf = 1000001;//别赋予太大值,会
2011-08-14 15:58:51
852
原创 hdu 2809 God of War //状态压缩DP
用记忆话搜索的可能时间上稍微慢点。 /* 几个陷阱吧 一个是可能出现攻击比防御小的情况,那么取伤害为1 另一种就是经验不清零,题目没提及吧 */ #include #include struct LVBU { int ATI,DEF,HP,EXP,level; }p
2011-08-14 14:58:25
1168
原创 hdu 3602 2012
变形的背包。 #include #include #include using namespace std; int a[110], b[110]; int dp[110][10100][2]; int main() { int T; scanf(
2011-08-14 12:42:13
750
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人
RSS订阅