
搜索
oranges_c
落寞是岁月的痕迹
展开
-
【POJ3414】Pots(BFS)
就是把操作用string保存。#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio>#include <iostream>#include <cstring>#include <string>#include <algorithm>#include <cstdlib>#in原创 2016-10-21 20:06:37 · 240 阅读 · 0 评论 -
【HDU6060】RXD and dividing(dfs)
RXD has a tree T, with the size of n. Each edge has a cost.Define f(S) as the the cost of the minimal Steiner Tree of the set S on tree T. he wants to divide 2,3,4,5,6,…n into k parts S1,S2,S3,…Sk,where原创 2017-08-02 14:44:29 · 438 阅读 · 0 评论 -
hdu_round1-1005 yyf倒水(bfs)
yyf和他女朋友到一家饭店吃饭,饭店里的服务员给yyf和女朋友每人一个杯子并把一个水壶放在了一边。女朋友想喝饮料,从饭店冰箱里拿来了一瓶“小茗同学”。倒满两个杯子后,yyf忍不住喝了一口,十分惬意。女朋友把两个杯子放在一起,认真地看了杯子里的水,向yyf问道,假设第一个杯子的容量是A升,第二个杯子的容量B升,两个杯子一开始都为空,现在有三个操作,1.FILL(i):将i杯子中的饮料倒满。2.EMPTY(i):将i杯子原创 2017-07-02 22:39:28 · 312 阅读 · 0 评论 -
队内训练赛二
A:ZOJ3158 Cut The Cake 题目大意: 给你一个m*n的矩阵,从上到下把它划分成两个子矩阵,两个子矩阵满足值的和的差不超过k,求最小的差值。 Note:不能在第一列的左边和最后一列的右边切。由于m,n值小,我们可以枚举切的位置直接搜索。在这之前我们要先预处理一下每一行的前缀和。方便搜索时记录最小值。#include <bits/stdc++.h>us原创 2017-04-02 17:54:50 · 341 阅读 · 0 评论 -
队内训练赛一
PS:因为备战省赛,并没有什么难的算法和数据结构。。A:HDU2181 哈密顿绕行世界问题 简单的dfs,每个城市只有三条边直接搜索即可。#include <bits/stdc++.h>using namespace std;#define ALL(v) (v).begin(),(v).end()#define cl(a,b) memset(a,b,sizeof(a)原创 2017-03-31 13:58:01 · 346 阅读 · 0 评论 -
团体程序设计天梯赛-练习集-L2-016. 愿天下有情人都是失散多年的兄妹(dfs)
题目链接一看题目,我以为可以用LCA算法写,写了半天,后来发现不是树(woc…) 再看题目,不超过5代,那么直接暴搜咯、、查询时,标记一个人的不超过5代的祖先,再从另一个人向上搜索在5代内是否有标记过的祖先。#include <bits/stdc++.h>using namespace std;#define ALL(v) (v).begin(),(v).end()#原创 2017-03-14 18:08:27 · 590 阅读 · 0 评论 -
PAT(A)-1102. Invert a Binary Tree (25)(数据结构+bfs)
题目链接题目大意: 给你n个点的树,让你输出层序和中序遍历序列。#include <bits/stdc++.h>using namespace std;#define ALL(v) (v).begin(),(v).end()#define cl(a,b) memset(a,b,sizeof(a))#define clr clear()#define pb push原创 2017-03-10 20:11:22 · 307 阅读 · 0 评论 -
ECPC16-E. Jumping(bfs)
题目链接题目大意: 给你n个数,a1,a2,...,ana_1,a_2,...,a_n表示在第i个点可以跳向i+aii+a_i点或i−aii-a_i点, 输出从每个点开始,跳向最后一个点步数。我们可以反着做,从最后一个点开始bfs,搜能跳向当前点的点。#include <bits/stdc++.h>using namespace std;#define ALL(v)原创 2017-03-10 20:08:18 · 722 阅读 · 0 评论 -
hiho一下 第140周-清理海报(DAG+dfs)
题目链接官方题解 题解里面貌似有错 这里应该还有条3->4的边有人会问为什么会有2->4这条边,从图上看2的四个点都被覆盖了。 这就是建图时要注意的地方了,建图时我们只要根据两个矩形是否相交建图就可以了,不必去管矩形的四个点是否被覆盖。 因为虽然2的四个点都被覆盖,但是2是作为1和4之间的关联的。撕1时,会先撕去2,然后再撕去4.所以这里要有条2->4的边。这样在原创 2017-03-05 12:52:36 · 295 阅读 · 0 评论 -
Codeforces Round #394 (Div. 2)-E. Dasha and Puzzle(dfs)
题目链接PS:看了半天题意没看懂。。题目大意: 给你N个点的树,问能否将这些点放在坐标平面上,要求边平行于坐标轴。首先一个点的度数不超过4。因为平面只有四个方向,若度数超过4,肯定不存在方案。 然后就以2^n为长度递减dfs放点。 ∑ni=12i<2n+1\sum_{i=1}^n2^i < 2^{n+1}#include <bits/stdc++.h>using na原创 2017-02-03 15:52:55 · 294 阅读 · 0 评论 -
【HDU1176】免费馅饼(记忆化搜索)
题目链接简单的记忆化搜索。#include <cstdio>#include <cstring>#include <algorithm>using namespace std;typedef long long LL;#define ALL(v) (v).begin(),(v).end()#define cl(a,b) memset(a,b,sizeof(a))原创 2017-02-14 14:05:24 · 401 阅读 · 0 评论 -
团体程序设计天梯赛-练习集-L2-013. 红色警报(dfs)
题目链接还记得这是去年决赛时L2的第一道题,当时还是有点懵。现在看看就是暴力的dfs。。#include <cstdio>#include <iostream>#include <cstring>#include <string>#include <algorithm>#include <vector>#include <set>#include <map>#原创 2017-02-11 16:43:09 · 373 阅读 · 0 评论 -
团体程序设计天梯赛-练习集-L3-004. 肿瘤诊断(三维bfs)
题目链接 这题原来写的是dfs。结果给我段错误,应该是爆栈了?后来改成了三维bfs#include <cstdio>#include <iostream>#include <cstring>#include <algorithm>#include <queue>using namespace std;#define ALL(v) (v).begin(),(v).原创 2017-02-10 16:37:49 · 400 阅读 · 0 评论 -
未完成~【POJ搜索】
poj3414 http://poj.org/problem?id=3414 题目大意: 有两个容量为A,B的罐,有三种操作(实际上有六种),问能否使得其中的一个罐装满C容量。原创 2016-10-21 20:02:39 · 308 阅读 · 0 评论 -
【POJ1426】Find The Multiple(搜索+打表)
BFS加打表水过。。#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio>#include <iostream>#include <cstring>#include <string>#include <algorithm>#include <cstdlib>#include原创 2016-10-21 21:18:19 · 344 阅读 · 0 评论 -
【POJ2251】Dungeon Master(bfs)
简单的bfs求最短路径。 二维的相信都会。 这题是三维的,只是多加了两个操作。其他都一样。#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio>#include <iostream>#include <cstring>#include <string>#include <al原创 2016-10-22 13:16:25 · 297 阅读 · 0 评论 -
【POJ1321】棋盘问题(简单dfs)
之前搜索的题目接触的少。。现在多练练。。 这题的搜索很经典。#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio>#include <iostream>#include <cstring>#include <string>#include <algorithm>#inclu原创 2016-10-22 11:25:22 · 330 阅读 · 0 评论 -
【POJ1753】Flip Game(位压缩+bfs)
PS:对于位压缩接触不是很多,继续学习~#pragma comment(linker, "/STACK:1024000000,1024000000")#include <cstdio>#include <iostream>#include <cstring>#include <string>#include <algorithm>#include <cstdlib原创 2016-10-21 20:15:56 · 356 阅读 · 0 评论 -
【HDU6035】Colorful Tree(dfs,树形dp)
There is a tree with n nodes, each of which has a type of color represented by an integer, where the color of node i is ci.The path between each two different nodes is unique, of which we define the value as原创 2017-08-25 12:45:32 · 301 阅读 · 0 评论