bzoj4506: [Usaco2016 Jan]Fort Moo(暴力)】的更多相关文章

4506: [Usaco2016 Jan]Fort Moo Time Limit: 10 Sec  Memory Limit: 128 MBSubmit: 145  Solved: 104[Submit][Status][Discuss] Description Bessie正在和她的朋友Elsie建一座堡垒.像任何好的堡垒一样,这需要从一个坚固的框架开始.Bessie想要在一 个矩形上建造堡垒,并在矩形周围围上1x1的框架.Bessie已经选择了一个建造堡垒的地方 —— 一块长宽分别为 为NM…
传送门 总之可以先预处理出来每个位置最多往上延伸多少 枚举两行,看看夹在这两行中间的列最大能构成多大的矩形 可以看出,必须得在一个两行都没有X的区间才有可能构成最大的答案 那么可以把这些区间处理出来,在看看这些区间中的点最左边和最右边的能从下面那一行向上延伸到上面那一行的点,更新ans即可 #include <cstdio> #define N 201 #define max(x, y) ((x) > (y) ? (x) : (y)) int n, m, ans, p; int h[N]…
4506: [Usaco2016 Jan]Fort Moo Description Bessie is building a fort with her friend Elsie. Like any good fort, this one needs to start with a sturdy frame. Bessie wants to build a frame in the shape of a one-meter-wide rectangular outline, atop which…
[洛谷P3135][USACO16JAN]堡哞Fort Moo Bessie和她的朋友Elsie正在建筑一个堡垒,与任何一个好的堡垒一样,这个需要一个强固的框架.Bessie想造一个轮廓是1m宽的空心矩形框架,这样堡垒就可以造在框架上了. Bessie以及选了一个地点建筑堡垒,一片N*M(1<=N,M<=200)的平地.不幸的是,这个地方有一些沼泽地而不可以支撑框架.请帮助Bessie决定最大她可以用堡垒覆盖的区域(即支撑框架的区域),而且避免框架在任何一块沼泽地上. 朴素暴力用前缀和优化成\…
bzoj4512[Usaco2016 Jan] Build Gates 题意: 某人从农场的(0,0)出发,沿边界到处乱走,走过的地方会留下栅栏,等走完后问要在多少个栅栏上开门才能使整个农场连通,最多走1000步. 题解: 我的代码比别人的都长~我的做法是先算出最左/最下可能会走到哪里,然后变换一下坐标系(实际是是改变出发起点),然后记录哪个格子的上下左右被栅栏堵了,最后做一下floodfill,输出连通块数-1.注意还要把有栅栏区域的外圈格子也算进去,因为它们代表了有栅栏区域外的广大地区(这个…
题目大意:给个序列,求最长的连续子序列使其为7的倍数 又是一道令人欢喜的不用怎么用脑的水题.. 边读入,边计算前缀和 分别保存前缀和%7结果为1,2,3,4,5,6的第一次的位置 然后减一减就知道长度啦. #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; ],ans; ]; int main(){ scanf("%d", &n); ans…
1.题意:给一堆可以的限制长度的区间...区间的长度是你控制的...但是只有一个长度...求最短长度覆盖所有的点 2.分析:发现可以二分...那二分吧.....然后我们从头向后扫一遍直接判断能否直接覆盖...然后就可以AC了<大赛后一水系列> #include <map> #include <set> #include <queue> #include <cmath> #include <cstdio> #include <cs…
二分. #include<cstdio> #include<algorithm> #include<cstring> using namespace std; + ; int n,k,l,r,mid,ans,d; int a[maxn]; bool check(int dist) { dist=*dist; ,sum=; ;i<=n;i++) { ]>dist-d) { sum++; d=; } ]; } //printf("%d %d\n&quo…
前缀和. 设f[i]为前缀和%7=i的第一个点.那么答案就是max(i-f[s[i]%7])了. #include<cstdio> #include<algorithm> #include<cstring> using namespace std; + ; int a[maxn],s[maxn]; ],n,ans; int main() { ;i<;i++) f[i]=-; scanf("%d",&n); ;i<=n;i++) {…
无线电联系 Radio Contact 题目描述 Farmer John has lost his favorite cow bell, and Bessie the cow has agreed to help him find it! They both fan out and search the farm along different paths, but stay in contact via radio so they can keep in touch with each-oth…