- 博客(583)
- 收藏
- 关注
原创 线段树整理
开始PHD生涯,好久不做题了,手生的不行,代码能力、算法能力直线下滑。不管以后我做什么方向,做做题目能很好地锻炼我的思维,所以以后开始继续做题,纯粹为了玩!先整理一下线段树方面的题目吧,最近项目有用到。
2013-09-28 20:18:04
1986
原创 zoj 3583 Simple Path
自从区域赛以后就没参加浙大月赛这种比赛了这题比赛的时候也没有过有两种解法,这种是并查集想象一下从s到t的一条简单路,想想简单路上每个点的性质:比如简单路上的点i,不管删去图上任何一个点,点i总会至少与s或t在一个相连的集合中另外想想不在简单路上的点j,一定可以找到一个点,使得j与s和t都不在一个相连的集合中用这种性质即可证明#include #include c
2012-03-13 19:51:11
1759
2
原创 HDU 4107
线段树的题目#include #define LL(x) x << 1#define RR(x) x << 1 | 1const 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
1323
原创 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
1107
原创 SPOJ 1793. Text Generater II
AC自动机+矩阵乘法+容斥原理刚开始是用单纯的状态压缩,当然是TLE后来用容斥原理,接着几乎快了64倍还多,接着各种弄,就过了2.99S,不知道那些弄到0.05秒的神牛怎么弄的
2011-10-01 19:43:39
1155
原创 hdu 3442 Three Kingdoms
状态压缩+BFS //记忆话搜索#include #include #include using namespace std;char map[55][55];int mp[55][55];int dp[55][55][1int dx[4]
2011-09-09 11:39:26
1195
原创 zoj 1015 Fishing Net//弦图的判定
整理一下乱七八糟的知识点#include#includeusing namespace std;const int maxn = 1010;const int inf = 100000000;struct EDGE{ int v, next;}e
2011-09-07 10:56:16
1850
原创 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
1091
原创 poj 1222 EXTENDED LIGHTS OUT //高斯消元
整理一下这块而已#include#include#include#include#includeusing namespace std;#define MAX_VAR 110 //geshu#define MAX_EQU 110 //位数#define M
2011-09-06 19:49:53
1202
原创 hdu 3584 Cube //三维树状数组
由二维的推一下就好了注意一下三维空间的容斥性,更新的时候注意一下这是区间更新,单点查询仔细想一想为什么可以这么做 Add(x1, y1, z1, 1); Add(x2+1, y1,
2011-09-06 11:23:04
994
原创 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
1089
原创 hdu 3517 Adopt or not
很明显就是求最大独立集,求什么就用什么当两边主要是找最大独立集的必须点首先是如果一个点没有匹配过,那么删除这个点,对匹配数无影响,所以一定是独立集中的接着对匹配中的点,某些点也一定是独立集中辨别的方法是,比如A和B匹配,如果A不去匹配B,而
2011-09-06 10:43:39
2303
原创 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
3246
原创 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
1076
原创 hdu 4009 Transfer water
#include#include#define SIZE 1100#define TYPE intstruct point{ int x, y, z;}node[1010];struct Edge{ int f,t; TYPE cost;
2011-09-04 15:29:53
897
原创 最小树形图
poj 3164 Command Network#include#include#include#includeusing namespace std;#define maxn 120#define INF 99999999999.0int n,m;
2011-09-04 10:28:13
738
原创 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
1266
原创 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
1115
原创 hdu 3987 Harry Potter and the Forbidden Forest//边数最小的最小割 2种解题方法
每条边的权值改为w*(M+1)+1最后得到的和sumsum div (M+1) 得到的是最小割的值,用(M+1)是为了不被后面的1影响到sum mod (M+1)得到的是最小割的边数,这个是在上面的最小割前提下求出来的(YY一下,在原题中可能存在多组割边,边数不同,
2011-09-02 11:02:52
1143
原创 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
1120
原创 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
933
原创 hdu 3478 //判联通+二分图判定
#include#includeconst 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
1029
原创 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
1311
原创 hdu 3627 Giant For //线段树
首先以x为第一关键字,y为第二关键字进行排序,离散化得到一个长度为num的数组(任何一次查询对应的点都能在这个数组中找到)对此进行建树比如进行第i次操作找到其在数组中对应的点pos那么pos--->num这里面的所有点的x值都大于等于pos点看这一段序列是
2011-08-29 15:37:43
1065
原创 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
670
原创 hdu 3030 Increasing Speed Limits
就是在一个500000的串里找除上升子序列的个数还是比较容易想到DP转移方程的dp[i] = sum(dp[j]|jdp[i]就是说以i结尾的上升子序列的个数现在是平方级的算法找一个上升子序列,很容易想到是树状数组注意一下离
2011-08-27 11:12:11
1082
原创 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
1851
原创 反思
听了ZZC师兄的分析,还是感觉要反思一番是否真的过于注重实现而没有注重思维的转化?跟真正强队的区别为什么永远追不上?训练方法肯定有问题做的题目也过于陈旧反思吧。
2011-08-22 19:05:10
1099
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
720
原创 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
900
原创 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
808
原创 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
1172
原创 poj 1185 炮兵阵地 //状态压缩DP
注意只有一行等这些特殊情况这种状态压缩DP还是比较简单的,这个题是前2行推出下一行的状态#include #include #include using namespace std;const int MAXN = (1 << 10);int n
2011-08-15 21:24:52
618
原创 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
568
原创 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
1332
原创 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
829
原创 hdu 2809 God of War //状态压缩DP
用记忆话搜索的可能时间上稍微慢点。/*几个陷阱吧一个是可能出现攻击比防御小的情况,那么取伤害为1另一种就是经验不清零,题目没提及吧*/#include #include struct LVBU{ int ATI,DEF,HP,EXP,level;}p
2011-08-14 14:58:25
1135
原创 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
727
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人