![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
STL dfs
twh233
嘻嘻
展开
-
poj2488 dfs模版
/* _...---.._ ,' ~~"--.. / ~"-._ / ~-. / . `-. \ -.\原创 2016-12-20 00:07:25 · 196 阅读 · 0 评论 -
Codeforces Round #430 (Div. 2) C. Ilya And The Tree dfs+set
传送门C. Ilya And The Treetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputIlya is very fond o原创 2017-09-02 00:14:14 · 208 阅读 · 0 评论 -
1450: 经商 01背包 dfs标记
传送门Sample Input15 3 75 103 24 31 1001 22 31 4Sample Output10题意懒得说了,中文题啊做法:01背包 01背包 01背包啊,dfs判连接啊//china no.1#pragma comment(linker, "/STACK:1024000000,102400000原创 2017-09-28 18:30:19 · 324 阅读 · 0 评论 -
贝伦卡斯泰露
传送门分成两个部分,有顺序 dfs//china no.1#pragma comment(linker, "/STACK:1024000000,1024000000")#include #include #include #include #include #include #include #include #include #include原创 2017-10-10 12:19:50 · 1227 阅读 · 0 评论 -
hdu 5937 Equation dfs
传送门题意:输入c[1]~c[9]分别表示1~9这些数字的个数,现在用这些数字构成等式x+y=z(x,y,z都是个位的数字),等式不能相同(1+2=3与2+1=3不同),求最多能都成多少个等式?做法:感觉x+y=z在1-9里面构成不会很多,事实也是如此,那么dfs是最好的选择了,不过有一个地方得剪枝。if(num+36-xx///原创 2017-10-12 16:53:49 · 217 阅读 · 0 评论 -
Educational Codeforces Round 30 D.Merge Sort
传送门题意:有一个函数,每调用一次排一次序,这个就是归并排序,给你n代表你要构造的序列长度,k代表你调用函数次数。做法:dfs模拟因为每次调用,一定是用两次,而且,左大右小才调用,自然而然k-=2。/// .-~~~~~~~~~-._ _.-~~~~~~~~~-./// __.原创 2017-10-13 23:35:00 · 173 阅读 · 0 评论 -
Educational Codeforces Round 31 C. Bertown Subway dfs
http://codeforces.com/contest/884/problem/C题意:给定n个车站,每个车站都有一辆发往目的地pi的车,(1问在交换其中任意两个车站的条件下,如何使得便利值最大。等于多个连通块,找最大的两个连通块,让他俩连起来就最大了。写得有点丑。/// .-~~~~~~~~~-.原创 2017-11-09 17:43:49 · 260 阅读 · 0 评论 -
VK Cup 2017 - Qualification 2 C. Online Courses In BSU
http://codeforces.com/problemset/problem/770/C题目大意:一共有N个科目,其中有M个主要科目,只要M个主要科目都通过了,那么对应主人公就可以毕业了,也就是达成了目的。现在有一个列表,表示要通过第i门课程需要先通过的科目列表。现在主人公希望得到一个通过科目的顺序,使得最终他通过最少的科目使得主人公毕业。做法:第一原创 2017-11-05 17:02:11 · 394 阅读 · 0 评论 -
北京师范大学第十四届ACM决赛- K ACM Battle 爆搜
https://www.nowcoder.com/acm/contest/12/K注意题目条件,只有10滴圣水。爆搜一下。/// .-~~~~~~~~~-._ _.-~~~~~~~~~-./// __.' ~. .~ `.__///原创 2017-11-16 19:00:03 · 185 阅读 · 0 评论 -
Codeforces Round #449 (Div. 2) C. Nephren gives a riddle 递归
http://codeforces.com/contest/897/problem/C又是正视了自己的递归水平,55555。题意:递归又递归的字符串 下面q个询问,第fn个字符串的第k个字符是啥,如果fn没k这么长就是.做法:递归长度,n很大,先处理n,如果n k一直很大,可以先判断他是在哪个范围,至少得突破最左边的边缘区,就是34那一块,所以先不断减小n,k达原创 2017-12-03 12:01:16 · 229 阅读 · 0 评论 -
bzoj1086 王室联邦 (树上分块
题目链接 题解:思想上是深搜+栈,每当栈中元素达到b个,就分成一个块。然后最后会剩下部分,分到最后一个块中。 /// .-~~~~~~~~~-._ _.-~~~~~~~~~-./// __.' ~. .~ `.__/// .'//...原创 2018-09-18 16:36:51 · 191 阅读 · 0 评论 -
冰淇淋(图形递归
传送门垃圾佬的冰淇淋TimeLimit:1000MS MemoryLimit:128MB64-bit integer IO format:%lld已解决 | 点击收藏Problem Description垃圾佬在草稿纸上画了一颗爱心,如下/\/\\ / \/垃圾佬发现,3颗爱心可以拼接成一个冰淇原创 2017-08-14 18:30:57 · 953 阅读 · 0 评论 -
Codeforces Round #428 (Div. 2) C. Journey(dfs deep
传送门C. Journeytime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThere are n cities and n - 1 roads in原创 2017-08-13 12:49:43 · 356 阅读 · 0 评论 -
神奇递归Gym - 100883F
While I was working in the company, the internet broke. I didn't have anything to do without internet, so I decided to write this ACM problem.We need to mix between two strings and also we should原创 2017-03-15 00:18:36 · 247 阅读 · 0 评论 -
Heavy Coins
Gym 100712GHeavy CoinsBahosain has a lot of coins in his pocket. These coins are really heavy, so he always tries to get rid of some ofthe coins by using them when paying for the taxi.When原创 2017-02-15 17:01:59 · 336 阅读 · 0 评论 -
L2-020. 功夫传人 CCCC-DFS
点击打开链接#include //#include //#include //using namespace __gnu_pbds;using namespace std;#define pi acos(-1)#define endl '\n'#define me(x) memset(x,0,sizeof(x));#define foreach(it,a)原创 2017-03-28 23:26:23 · 502 阅读 · 0 评论 -
Gym - 100735H
Informikas was cleaning his drawers while he found a toy of his childhood. Well, it's not just a toy, it's a bunch of cubes with letters and digits written on them.Informikas remembers that he could原创 2017-02-18 11:21:43 · 421 阅读 · 0 评论 -
poj 1686
传送门Lazy Math InstructorTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 3993 Accepted: 1393DescriptionA math instructor is too lazy to grade a qu原创 2017-04-26 23:56:13 · 399 阅读 · 0 评论 -
Codeforces Round #413 D. Field expansion (搜索)
传送门题意将原 h×w 的矩形扩展,使得其能够放置 a×b 的矩形。每次扩展可以从给定的 n (n≤100000) 个数中选择一个数 Ai,将 h→h⋅Ai 或者 w→w⋅Ai ,其中每个数最多只能使用一次,问最少扩展多少次能满足条件,或不可能。解题思路首先可以想到,对于同样地对原矩形扩展 X 次,使用 n 个数中最大的 X 个数对矩形进行扩原创 2017-05-14 23:55:09 · 397 阅读 · 0 评论 -
别墅房间
别墅房间时间限制(普通/Java) : 1000 MS/ 3000 MS 运行内存限制 : 65536 KByte总提交 : 120 测试通过 : 31 描述C大佬到他的朋友家别墅去玩,发现他朋友的家非常大,而且布局很奇怪。具体来说,朋友家的别墅可以被看做一个N*M的矩阵,有墙壁的地方被标记为’#’,其他地方被标记为’原创 2016-12-20 00:01:29 · 310 阅读 · 0 评论 -
poj 1321
传送门Description在一个给定形状的棋盘(形状可能是不规则的)上面摆放棋子,棋子没有区别。要求摆放时任意的两个棋子不能放在棋盘中的同一行或者同一列,请编程求解对于给定形状和大小的棋盘,摆放k个棋子的所有可行的摆放方案C。Input输入含有多组测试数据。 每组数据的第一行是两个正整数,n k,用一个空格隔开,表示了将在一个n*n的矩阵内描述棋盘,以及摆原创 2017-04-24 16:44:22 · 185 阅读 · 0 评论 -
51nod 1489
#include //#include //#include //using namespace __gnu_pbds;using namespace std;#define pi acos(-1)#define endl '\n'#define me(x) memset(x,0,sizeof(x));#define foreach(it,a) for(__typeof((a原创 2017-03-30 23:13:15 · 313 阅读 · 0 评论 -
2017 计蒜之道 初赛 第三场 腾讯狼人杀(简单)(暴搜)
传送门不久前,腾讯推出了一款改进后的狼人杀游戏。如下是这款游戏的背景和详细规则:很久很久以前,在莱茵河畔一座岸壁陡峭的山顶上,有一个名叫“杜斯特瓦德”的小村庄。不久前,这个小村庄每晚都会受到狼人的侵袭。每个夜晚,狼人都会在村中进行抢劫,并且会有一个村民成为这群狼人的牺牲品。然而村民们不会坐以待毙,他们试图在白天找到这些狼人并处决他们。作为杜斯特瓦德村的长老,你需要组织村民来对抗狼人,村原创 2017-06-20 22:36:29 · 410 阅读 · 0 评论 -
Educational Codeforces Round 22 C. The Tag Game 搜索
传送门C. The Tag Gametime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputAlice got tired of playin原创 2017-06-10 17:49:19 · 293 阅读 · 0 评论 -
牛客练习赛9 B.珂朵莉的值域连续段 dfs
题目链接 维护每个点节点的儿子个数,最大值最小值。如果最大值-最小值+1=儿子个数,那么这个子树是满足条件的 /// .-~~~~~~~~~-._ _.-~~~~~~~~~-./// __.' ~. .~ `.__/// .'// ...原创 2018-09-29 17:05:06 · 101 阅读 · 0 评论