码迷,mamicode.com
首页 >  
搜索关键字:dfs    ( 10564个结果
HDU1179_Ollivanders: Makers of Fine Wands since 382 BC.(二分图/最大匹配)
解题报告 题意: n个巫师m个魔杖,每个魔杖可以被不同的巫师使用。求多少个魔杖会被买。 思路: 二分图最大匹配简单题。 #include #include #include using namespace std; int mmap[110][110],n,m,vis[110],pre[110]; int dfs(int x) { for(int i=1; i<=n; i...
分类:其他好文   时间:2014-08-15 16:02:39    阅读次数:258
zoj 1008 Gnome Tetravex (dfs+枚举)
Gnome Tetravex Time Limit: 10 Seconds      Memory Limit: 32768 KB Hart is engaged in playing an interesting game, Gnome Tetravex, these days. In the game, at the beginning, the player is given...
分类:其他好文   时间:2014-08-15 16:00:49    阅读次数:270
HDU1253
一个简单的三维BFS: 刚开始说内存超出了,就把 标记走过的路语句 和 判断到达终点的语句 放在了push(next)之前 #include #include #include #include #define N 51 using namespace std; struct node{ int x,y,z; int t; }; int dir[8]...
分类:其他好文   时间:2014-08-15 14:45:28    阅读次数:292
CodeForces 29D Ant on the Tree
给一颗树,1为根,要求遍历树上所有点,给出叶子结点的访问顺序,限制每条边至多访问两次。 首先这是一棵树,那么两点之间的路线是确定的,所以我第一遍dfs预处理出从根节点到每个叶子的路径保存,以便后面输出。 那么就按照题目要求输出叶子结点的顺序依次输出,然后从一个叶子到下一个叶子的时候,从他们的最近公共祖先转折,所以我还预处理了相邻两个叶子结点的LCA。 #include...
分类:其他好文   时间:2014-08-15 14:37:08    阅读次数:220
PKU 1562/HDU 1241 Oil Deposits(原油有多少块区域---BFS,DFS)
Oil Deposits Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u Description The GeoSurvComp geologic survey company is responsible for detecting underground oil ...
分类:其他好文   时间:2014-08-15 12:59:08    阅读次数:208
UVA-6436 The Busiest City 树形DFS求解
给出n个顶点,n-1条边,对于每一个顶点来说每有一条路径经过,繁荣度+1,求最大繁荣度。 经过的含义就是这条路径使用了跟这个顶点相连的边中的的两条,任意组合都可以,所以要找出每个顶点相连的边延伸出去有多少种情况。 从第一个顶点开始建树,对于第i个节点有sum[i]个子节点,因此dp[i]=sum[i]*(n-1-sum[i]),再加上节点的n棵子树的节点数乘积/2。 #include #i...
分类:其他好文   时间:2014-08-15 10:43:48    阅读次数:233
POJ 1130(一道纯水,bfs+dfs)
POJ 1130  大概题意:给出一副图,求从起点到终点 (0->ET) 必须经过的一点。 我的思路:首先DFS求出经过每点的次数,必过的一点的次数一定最高,但是就这样吗?有可能有多个必过的点,所以还要找出离ET最近的点,这里就利用BFS逐层搜索的性质求每点到ET的距离。 #include #include #include #include #include ...
分类:其他好文   时间:2014-08-15 10:43:08    阅读次数:207
poj 1321 棋盘问题 【DFS】
题意:。。。 策略:深搜. 仔细分析我们发现,我们只需要对列进行标记,对于行我们考虑放棋子还是不放就行了。 代码: #include #include char s[10][10]; int n, m; int vis[10]; int ans; void dfs(int cur, int step) { if(step == m){ ans ++; return; } if...
分类:其他好文   时间:2014-08-15 09:30:27    阅读次数:153
HDU1010 Tempter of the Bone 【DFS】+【剪枝】
Tempter of the Bone Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 70895    Accepted Submission(s): 19535 Problem Description The ...
分类:其他好文   时间:2014-08-15 00:08:56    阅读次数:323
HDU2063_过山车(二分图/最大匹配)
解题报告 题目传送门 题意: 求最大的男女匹配数目。 思路: 简单的最大匹配。 #include #include #include using namespace std; int k,n,m,mmap[1100][1100],vis[550],pre[550]; int dfs(int x) { for(int i=1;i<=n;i++){ if(!v...
分类:其他好文   时间:2014-08-15 00:07:56    阅读次数:262
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!