POJ 1636 Prison rearrangement DFS+0/1背包】的更多相关文章

题目链接: id=1636">POJ 1636 Prison rearrangement Prison rearrangement Time Limit: 3000MS   Memory Limit: 10000K Total Submissions: 2194   Accepted: 984 Description In order to lower the risk of riots and escape attempts, the boards of two nearby priso…
Prison rearrangement   Time Limit: 3000MS   Memory Limit: 10000K Total Submissions: 2158   Accepted: 971 Description In order to lower the risk of riots and escape attempts, the boards of two nearby prisons of equal prisoner capacity, have decided to…
题目链接:http://poj.org/problem?id=1745 Divisibility Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 13431   Accepted: 4774 Description Consider an arbitrary sequence of integers. One can place + or - operators between integers in the sequen…
题目链接 http://poj.org/problem?id=1426 题意 输入一个数n,输出任意一个 只含0.1且能被n整除的数m.保证n<=200,m最多100位. 题解 DFS/BFS都能做. 这里使用DFS.然后T了.就变成了打表A了.emm ,m最多会19位,这点我也很迷==. 其他 使用了Java大数,get了打开方式. todo 为啥m19?? BFS法 0/1背包法 和鸽笼原理有什么关系? 代码 打表A版 import java.math.BigInteger; import…
Sticks Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 127771   Accepted: 29926 Description George took sticks of the same length and cut them randomly until all parts became at most 50 units long. Now he wants to return sticks to the or…
题目:http://poj.org/problem?id=1753 这个题在開始接触的训练计划的时候做过,当时用的是DFS遍历,其机制就是把每一个棋子翻一遍.然后顺利的过了.所以也就没有深究. 省赛前一次做PC2遇到了差点儿一模一样的题,仅仅只是是把棋盘的界限由4X4改为了5X5,然后一直跑不出结果来,可是当时崔老湿那个队过了,在最后总结的时候.崔老湿就说和这个题一样,只是要枚举第一行进行优化. 我以为就是恢复第一行然后第二行以此类推,只是手推一下结果是6不是4,就知道这个有问题. 问了崔老湿,…
http://poj.org/problem?id=1011 题意:若干根棍子被截成小段的木棒,现在给你这些木棒,问最短可以拼出的棍子长度. 题解:搜索,dfs(r,m) 二个参数分别代表还剩r个木棒,当前棍子还剩m长度. 从dfs(N,L)搜到dfs(0,0)停止. 棍子从大到小排序 从小到大枚举L 四个剪枝 0.考虑木棒大多都一样长的特殊情况. 多余的枚举: “如果某个木棒在当前棍子不能用,那么之后必定会用到” 1.第一个木棒回溯时(由于后续无法继续拼接导致不能用),后面总归会还是要把它作…
POJ.3321 Apple Tree ( DFS序 线段树 单点更新 区间求和) 题意分析 卡卡屋前有一株苹果树,每年秋天,树上长了许多苹果.卡卡很喜欢苹果.树上有N个节点,卡卡给他们编号1到N,根的编号永远是1.每个节点上最多结一个苹果.卡卡想要了解某一个子树上一共结了多少苹果. 现在的问题是不断会有新的苹果长出来,卡卡也随时可能摘掉一个苹果吃掉.你能帮助卡卡吗? 前缀技能 边表存储树 DFS时间戳 线段树 首先利用边表将树存储下来,然后DFS打上时间戳.打上时间戳之后,我们就知道书上节点对…
看题传送门:http://poj.org/problem?id=1753 DFS枚举的应用. 基本上是参考大神的.... 学习学习.. #include<cstdio> #include<iostream> using namespace std; int n,s,d,ans; bool a[5][5],flag=false; //判断全部一样的情况 bool alllike() { for(int i=0;i<4;i++) for(int j=0;j<4;j++) i…
POJ 1321 题目大意:给定一棋盘,在其棋盘区域放置棋子,需保证每行每列都只有一颗棋子. (注意 .不可放 #可放) 解题思路:利用DFS,从第一行开始依次往下遍历,列是否已经放置棋子用一个数组标记,直至放完要求的棋子数. /*POJ 1321 棋盘问题 --- DFS*/ #include <cstdio> #include <cstring> int n, k, cnt; ]; //标记列的访问状态 ][]; /*从第r行开始正确放置p个棋子*/ void dfs(int…