码迷,mamicode.com
首页 >  
搜索关键字:DFS Troubleshooting    ( 10753个结果
SGU 319 Kalevich Strikes Back(线段树扫描线)
题目大意:n个矩形,将一个大矩形分成 n+1 块。矩形之间不重合,可是包括。求这n+1个矩形的面积思路分析:用线段树记录他们之间的父子关系。然后dfs 计算面积。当给出的矩形上边的时候,就要记录到该矩形的父亲去。#include #include #include #include #define ...
分类:其他好文   时间:2014-08-28 22:38:26    阅读次数:357
求树的最长链
2次dfs的方法: 1 void dfs(int u,int step) 2 { 3 int tmp=0; 4 if (step>t) 5 { 6 max_dist=step; 7 max_point=u; 8 } 9 for ...
分类:其他好文   时间:2014-08-28 22:22:26    阅读次数:212
hdu4751Divide Groups(dfs枚举完全图集合或者bfs染色)
1 /************************************************************************* 2 > File Name: j.cpp 3 > Author: HJZ 4 > Mail: 2570230521@qq...
分类:其他好文   时间:2014-08-28 18:03:05    阅读次数:338
hdoj 3491 Thieves 【最小割 + 拆点】
题目:hdoj 3491 Thieves  题意:给出一个无向图,然后有个出发城市s,结束城市 t ,然后每个点有流量限制,问你最少用多少的人能够使得 s 到 t 没有流量。 分析:题意是抽象出来的,但是很明显看出来是求最小割。难点有2 1:无向图,所以要建双向边 2:点有流量限制,所以要拆点,拆成两个点,然后这两点的容量为点的限制,图中点的连接设置流量为inf,保证割不掉...
分类:其他好文   时间:2014-08-28 11:33:19    阅读次数:180
ural 1500 Pass Licenses (状态压缩+dfs)
1500. Pass LicensesTime limit: 2.5 secondMemory limit: 64 MBA New Russian Kolyan believes that to spend his time in traffic jams is below his dignity....
分类:其他好文   时间:2014-08-28 11:01:19    阅读次数:303
UVA 11748 - Rigging Elections(dfs)
UVA 11748 - Rigging Elections 题目链接 题意:n个人选举,给出m个人的投票人对于每个人的优先级,现在你想让第c个人赢,问能不能 思路:对于两个人上场,如果a能赢b,就建一条a->b的边,然后问题其实就变成能否以c为根节点是一棵树,直接dfs一遍即可 代码: #include #include #include using names...
分类:其他好文   时间:2014-08-28 02:07:18    阅读次数:226
UVA 10441 - Catenyms(欧拉道路)
UVA 10441 - Catenyms 题目链接 题意:给定一些单词,求拼接起来,字典序最小的,注意这里的字典序为一个个单词比过去,并不是一个个字母 思路:欧拉回路,利用并查集判联通,然后欧拉道路判定,最后dfs输出路径 代码: #include #include #include #include #include #include using nam...
分类:其他好文   时间:2014-08-28 00:59:48    阅读次数:236
hdu 4771 求一点遍历所有给定点的最短路(bfs+dfs)
题目如题。题解如题。 由于目标点最多只有4个,先bfs出俩俩最短路(包括起点),再dfs最短路。)0s1A;(当年弱跪杭州之题,现看如此简单) #include #include #include #include #include using namespace std; struct point { int x,y; int cnt; }; char a[105][105]...
分类:其他好文   时间:2014-08-27 22:00:38    阅读次数:272
tarjan求强联通分量 模板
1 void tarjan(int u) 2 { 3 dfn[u]=low[u]=++dfs_clock; 4 stack_push(u); 5 6 for (int c=head[u];c;c=nxt[c]) 7 { 8 int v=to...
分类:移动开发   时间:2014-08-27 18:36:48    阅读次数:198
求割点 模板
1 void dfs(int u,int father) 2 { 3 int child=0; 4 dfn[u]=low[u]=++dfs_clock; 5 6 for (int c=head[u];c;c=nxt[c]) 7 { 8 in...
分类:其他好文   时间:2014-08-27 18:21:18    阅读次数:219
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!