深搜
everlasting__
'-'
展开
-
bzoj 1673: [Usaco2005 Dec]Scales 天平
→题目链接← 神奇的背包dfs 代码: #include #include #include #include #include #include #define inf 999999999 #define ll long long using namespace std; int n,m; ll a[1010]; ll sum[1010]; ll ans=0; vo原创 2017-08-15 11:02:50 · 284 阅读 · 0 评论 -
bzoj 1615: [Usaco2008 Mar]The Loathesome Hay Baler麻烦的干草打包机
→题目链接← 一个水题.... 找到从起点到终点的路径,然后算出所有的转速,最后加起来 因为一个齿轮不可能被两个齿轮驱动,所以从起点到终点一定只有一条路径 所以从起点开始,进行深搜就好,整个图像是一个树一样 存一下每个点的父亲节点,最后从终点向上一直找就是那条路经 注意: 1、转速进行运算时一定要用小数,有进位什么的 2、输出答案时不能直接printf("%0.lf",ans),这原创 2017-08-14 16:18:19 · 304 阅读 · 0 评论 -
bzoj 3385: [Usaco2004 Nov]Lake Counting 数池塘
→题目链接← 从左上角开始扫,扫到一个W时就开始dfs 把经过的地方W都变成. 只要有W在周围就接着dfs 然后这么一次dfs下来就找到了一个池塘 最后统计下数量 代码: #include #include #include #include using namespace std; char c[110][110]; int tox[8]={-1,-1,0,1,原创 2017-09-25 15:20:29 · 376 阅读 · 2 评论 -
bzoj 4749: [Usaco2016 Dec]Moocast dfs
→题目链接← 很水的dfs题 n^2的dfs,把每个点都当作起点跑一遍,最后取max 代码: #include #include #include #include using namespace std; struct node{ int x,y,p; }; int n; node a[220]; bool f[220]; int ans=0; double c原创 2017-09-02 13:25:06 · 411 阅读 · 0 评论 -
bzoj 1827: [Usaco2010 Mar]gather 奶牛大集会
→题目链接← 【想说的话】 没有什么想说的=.= 周末没什么事不刷题感觉不太好 【题解】 两遍dfs(树形dp) 将点1当作根 第一遍dfs计算出每个点子节点总数,还有将它作为集会地点时它的子树中的点满足条件需要的代价 第二遍计算出答案,点1的答案就是dfs1时处理出的代价,剩下的点的答案就对于它与它父亲节点的那条边计算一下就好 具体看代码吧 【代码】原创 2017-10-29 22:18:00 · 227 阅读 · 0 评论 -
bzoj 3391: [Usaco2004 Dec]Tree Cutting网络破坏
→题目链接← 【想说的话】 果然我还是比较喜欢树 【题解】原创 2017-11-15 20:30:02 · 241 阅读 · 0 评论