
ACM
DQZQ
这个作者很懒,什么都没留下…
展开
-
线段树的学习之--hdu1166敌兵布阵
#include #includeusing namespace std;struct Node{ int left,right,value;}st[150010];int a[150010];int T,n;void build(int left,int right,int root){ st[root].left=left; st[ro原创 2013-05-09 14:31:52 · 209 阅读 · 0 评论 -
动态规划学习系列三
一:最少拦截系统http://acm.hdu.edu.cn/showproblem.php?pid=1257 两种做法,一是贪心,从后往前贪;二是DP; if(v[i]>max{dp[j]}) (0 dp[len++]=v[i]; 贪心法:int i,n,count,a[1005],res,max; while (scanf("%d",&n原创 2013-06-12 11:40:58 · 277 阅读 · 0 评论 -
动态规划学习系列二
一:免费馅饼http://acm.hdu.edu.cn/showproblem.php?pid=1176 自底向上计算:dp[i][j]=max(dp[i+1][j-1],dp[i+1][j],dp[i+1][j+1])+v[i][j];处理边界,其中i表示时间,j表示小径上的标号int n;const int N=100003;int data[N][13];int V原创 2013-06-11 18:51:33 · 235 阅读 · 0 评论 -
动态规划学习系列
一:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2955这道题是,错误的认为题目所给的浮点型的数据都是精确到小数点后两位,然后把概率放大100倍,转换成为熟悉的01背包。。faint。。经测试题目的数据可能达到0.00001,甚至比0.00001还小,,所以必须转换思路,,于是转成以所有银行的总资产为背包容量V。。求最大的逃跑概率。。注原创 2013-06-10 17:14:59 · 233 阅读 · 0 评论 -
hdu1102最小生成树的解--prim算法和kruscal算法
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1102一;利用kruscal算法:利用到了并查集的思想。getParent()利用是一种两趟方法(two-path method),一趟是沿查找路径上升,直到找到根,第二趟是沿路径下降,以便更新每个节点使之直接指向根。另外按rank合并没有体现,其思想是为每个节点添加一个rank,好让合并的原创 2013-06-29 15:12:22 · 259 阅读 · 0 评论 -
Tire树的学习
本文参照http://blog.youkuaiyun.com/niushuai666/article/details/7002823,写的很详细。大体记住的是:插入节点。构建失败指针,查询散步操作。下面代码中的一个缺陷是没有对堆空间进行释放。#include #include#include#include#includeusing namespace std;const int原创 2013-07-31 21:34:18 · 220 阅读 · 0 评论 -
A*算法的学习
详细的A*算法参考文章:http://www.cppblog.com/mythit/archive/2009/04/19/80492.aspxhttp://acm.pku.edu.cn/JudgeOnline/problem?id=2243在国际象棋的棋盘上,一匹马共有8个可能的跳跃方向,求从起点到目标点之间的最少跳跃次数。#include #include#inclu原创 2013-08-01 14:22:25 · 243 阅读 · 0 评论 -
hdu1011 Starship Troopers 树形背包
http://acm.hdu.edu.cn/showproblem.php?pid=1011是有n个洞组成一棵树,你有m个士兵,你从1号房间开始攻打,每个洞有a个"bugs"和b的价值。你的一个士兵可以打20个"bugs",为了拿到这个洞的价值b你必须留下k个士兵消灭这个洞的所有"bugs"(k*20>="bugs"的数量,且留下的士兵不可以再去攻打其他的洞,且必须攻打了前面的洞才可以攻打后面原创 2013-09-06 09:59:53 · 420 阅读 · 0 评论 -
2013 ACM/ICPC Asia Regional Online —— Warmup 三个ACM热身赛题
三个题就做对一个,还是很有差距呀,第一个正确。第二三个没有AC,贴一下代码:#include#include#include#include#include#includeusing namespace std;inline char next(char t){ t=(t+1); if(t=='z'+1) t='a'; return t;}int main(原创 2013-09-08 15:27:12 · 388 阅读 · 0 评论 -
hdu1069 Monkey and Banana
题目链接点击打开链接#include #include#includeusing namespace std;struct Cube{ int x,y,z; Cube(){} Cube(int _x,int _y,int _z):x(_x),y(_y),z(_z){}}dp[200];//总共有30*3*2个状态bool cmp(const原创 2013-05-09 16:29:03 · 324 阅读 · 0 评论 -
hdu4109 Instruction Arrangement
题目链接:点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=4109利用帯负权图的最短路计算,原图的最长路#include using namespace std;const int N=10005;struct Node{ int b,e,w;}p[N];int dis[N],num,n;void inser原创 2013-05-12 18:25:17 · 248 阅读 · 0 评论 -
hdu1085 Holding Bin-Laden Captive!
一道母函数的题:点击打开链接代码:#include#include#include#include#include#include#include#includeusing namespace std;int c1[8100],c2[8002];int main() {#ifndef ONLINE_JUDGE freopen("in原创 2013-05-11 16:13:24 · 194 阅读 · 0 评论 -
hdu1070 MILK
Problem DescriptionIgnatius drinks milk everyday, now he is in the supermarket and he wants to choose a bottle of milk. There are many kinds of milk in the supermarket, so Ignatius wants to know whi原创 2013-05-09 19:31:37 · 241 阅读 · 0 评论 -
hdu1071 the area
Problem DescriptionIgnatius bought a land last week, but he didn't know the area of the land because the land is enclosed by a parabola and a straight line. The picture below shows the area. Now giv原创 2013-05-09 20:30:39 · 281 阅读 · 0 评论 -
hdu1043 Eight--分别用A*和IDA*的解法
Problem DescriptionThe 15-puzzle has been around for over 100 years; even if you don't know it by that name, you've seen it. It is constructed with 15 sliding tiles, each with a number from 1 to 15原创 2013-05-10 19:25:57 · 287 阅读 · 0 评论 -
hdu3062 Party 2-sat问题之一学习
题目链接:点击打开链接思路:根据不相容的集合组成有向图,然后在有向图中找极大连通子图,如果夫妻两个在同一个连通中,则无解。代码:#include#include #include using namespace std;const int N=2005;int dfn[N],low[N],ins[N],gin[N];vector gra[N];stack sta原创 2013-05-11 10:01:22 · 273 阅读 · 0 评论 -
hdu3622 Bomb Game--2-sat问题学习二
题目链接:点击打开链接思路:求出每顶点对之间的距离,然后unique一下,最后二分法解针对每个距离的可行性。代码:#include#include#include#include#includeusing namespace std;const int maxn=300;//tarjan 使用注意ini还有图开始的下标int low[maxn],dfn原创 2013-05-11 11:20:14 · 259 阅读 · 0 评论 -
hdu1072 Nightmare
Problem DescriptionIgnatius had a nightmare last night. He found himself in a labyrinth with a time bomb on him. The labyrinth has an exit, Ignatius should get out of the labyrinth before the bomb e原创 2013-05-09 22:24:56 · 173 阅读 · 0 评论 -
hdu1074 Doing Homework
题目链接:点击打开链接dp+状态压缩的题。代码:#include#include#include#include#include#include#include#includeusing namespace std;const int N=1<<16;struct Node { int time,dt; string name原创 2013-05-11 15:14:25 · 186 阅读 · 0 评论 -
hdu1077 Catching Fish
题目链接:点击打开链接感觉是在考基础,最开始一直在想有什么好的算法,结果也还是退回到枚举的思路上来了;枚举每一对顶点,如果距离大于2,则抛弃,否则,求出到这两点距离为1的圆心坐标,遍历所有点到这个圆心的距离,统计ans得到ans最大值即为问题的解#include#include#include#include#include#include#include原创 2013-05-11 19:14:43 · 241 阅读 · 0 评论 -
hdu3572 Task Schedule
求最大流的sap算法:点击打开链接#include using namespace std;const int nMax = 2000;const int mMax = 500000;const int INF = 0x7fffffff;struct Edge{ int v, w, next; Edge(){} Edge(int v, in原创 2013-05-12 13:58:04 · 219 阅读 · 0 评论 -
hdu1003 max sum
题目:点击打开链接Sample Input25 6 -1 5 4 -77 0 6 -1 1 -6 7 -5 Sample OutputCase 1:14 1 4Case 2:7 1 6int main() { freopen("in.txt","r",stdin); int T; cin>>T;原创 2013-09-27 20:17:12 · 219 阅读 · 0 评论