题目 1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec  Memory Limit: 64 MB Submit: 491  Solved: 218 [Submit][Status] Description The farm has many hills upon which Farmer John would like to place guards to ensure the safety of his valuable…
题目链接:http://www.lydsy.com/JudgeOnline/problem.php?id=1619 题意: 给你一个n*m的地形图,位置(x,y)的海拔为h[x][y]. 一个山顶的定义为:可以是一个点,或是一片海拔相同的区域. 要求为山顶周围(每个点的八个方向)的海拔均比山顶低(或为边界). 问你有多少个山顶. 题解: dfs灌水法. 将所有点按海拔从高到低排序. 依次从每个点灌水,水流到的地方做标记. 灌水:如果一个点有水,则它周围海拔比它低的点也会被水淹. AC Code:…
不是严格小于是小于等于啊!!!!!不是严格小于是小于等于啊!!!!!不是严格小于是小于等于啊!!!!! 是我看不懂人话还是翻译不说人话= = 把所有格子按值排个序,bfs扩展打标记即可 #include<iostream> #include<cstdio> #include<algorithm> #include<queue> using namespace std; const int N=705,dx[]={-1,-1,-1,0,0,1,1,1},dy[…
1619: [Usaco2008 Nov]Guarding the Farm 保卫牧场 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 498  Solved: 223[Submit][Status] Description The farm has many hills upon which Farmer John would like to place guards to ensure the safety of his valuable milk…
http://www.lydsy.com/JudgeOnline/problem.php?id=1619 首先不得不说,,题目没看懂.... 原来就是找一个下降的联通块.... 排序后dfs标记即可.. #include <cstdio> #include <cstring> #include <cmath> #include <string> #include <iostream> #include <algorithm> #inc…
Description The farm has many hills upon which Farmer John would like to place guards to ensure the safety of his valuable milk-cows. He wonders how many guards he will need if he wishes to put one on top of each hill. He has a map supplied as a matr…
Description The farm has many hills upon which Farmer John would like to place guards to ensure the safety of his valuable milk-cows. He wonders how many guards he will need if he wishes to put one on top of each hill. He has a map supplied as a matr…
BZOJ 1229: [USACO2008 Nov]toy 玩具 标签(空格分隔): OI-BZOJ OI-三分 OI-双端队列 OI-贪心 Time Limit: 10 Sec Memory Limit: 162 MB Description 玩具 [Chen Hu, 2006] Bessie的生日快到了, 她希望用D (1 <= D <= 100,000; 70%的测试数据都满足 1 <= D <= 500)天来庆祝. 奶牛们的注意力不会太集中, 因此Bessie想通过提供玩具…
二分一下答案就好了... ---------------------------------------------------------------------------------------- #include<cstdio> #include<cstring> #include<algorithm> #include<cctype> #include<iostream>   #define rep( i , n ) for( int…
状压dp dp( x , S ) 表示最后一个是 x , 当前选的奶牛集合为 S , 则状态转移方程 : dp( x , S ) =  Σ dp( i , S - { i } )  ( i ∈ S , abs( h[ i ] - h[ x ] ) > k ) ------------------------------------------------------------------------------------------- #include<cstdio> #includ…