|BZOJ 1661|暴力|[Usaco2006 Nov]Big Square 巨大正方形
来源:互联网 发布:linux的启动过程 编辑:程序博客网 时间:2024/05/19 15:41
BZOJ 1661
Luogu 2867
from: USACO 2006 Nov Sliver(USACO刷题第7题)
枚举两个点,第二个点要在第一个点的右下,那么这样我们就可以根据一个公式来求另外两个点了。之后四个点求出来后判断四个点是否都可行,然后记录这四个点中J的数量,如果
#include<cstdio>#include<cstring>#include<algorithm>#include<stack>#include<vector>#define ms(i, j) memset(i, j, sizeof i)#define LL long longusing namespace std;const int MAXN = 100 + 5;int n;char s[MAXN][MAXN];void clear() {}void init() { clear(); for (int i=1;i<=n;i++) scanf("%s", s[i]+1);}void solve() { int ans = 0; for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) for (int x=i+1;x<=n;x++) for (int y=1;y<=j;y++) { int si = j - y, ti = x - i; int x3 = i + si, y3 = j + ti, x4 = x + si, y4 = y + ti; if (x3<=0||x3>n||x4<=0||x4>n||y3<=0||y3>n||y4<=0||y4>n) continue; if (s[i][j]=='B'||s[x][y]=='B'||s[x3][y3]=='B'||s[x4][y4]=='B') continue; int tot = 0; if (s[i][j]=='J') tot++; if (s[x][y]=='J') tot++; if (s[x3][y3]=='J') tot++; if (s[x4][y4]=='J') tot++; if (tot>=3) ans = max(ans, si*si+ti*ti); } printf("%d\n", ans);}int main() { #ifndef ONLINE_JUDGE freopen("1.in", "r", stdin);freopen("1.out", "w", stdout); #endif while (scanf("%d", &n)==1&&n) init(), solve(); return 0;}
阅读全文
1 0
- |BZOJ 1661|暴力|[Usaco2006 Nov]Big Square 巨大正方形
- bzoj 1661 [Usaco2006 Nov]Big Square 巨大正方形
- bzoj 1661: [Usaco2006 Nov]Big Square 巨大正方形 (枚举)
- bzoj 1661: [Usaco2006 Nov]Big Square 巨大正方形 解题报告
- bzoj 1661: [Usaco2006 Nov]Big Square 巨大正方形(枚举)
- 1661: [Usaco2006 Nov]Big Square 巨大正方形
- BZOJ 1726: [Usaco2006 Nov]Roadblocks第二短路
- bzoj 1726: [Usaco2006 Nov]Roadblocks第二短路
- BZOJ 1726 [Usaco2006 Nov]Roadblocks第二短路
- BZOJ 1660: [Usaco2006 Nov]Bad Hair Day 乱发节
- bzoj 1725: [Usaco2006 Nov]Corn Fields牧场的安排
- 【BZOJ 1660】 [Usaco2006 Nov]Bad Hair Day 乱发节
- BZOJ 1724: [Usaco2006 Nov]Fence Repair 切割木板
- BZOJ 1724 [Usaco2006 Nov]Fence Repair 切割木板
- BZOJ 1724 [Usaco2006 Nov]Fence Repair 切割木板 贪心+堆
- bzoj 1662: [Usaco2006 Nov]Round Numbers 圆环数(枚举)
- BZOJ 1724: [Usaco2006 Nov]Fence Repair 切割木板 堆
- bzoj 1669: [Usaco2006 Oct]Hungry Cows饥饿的奶牛 暴力
- 实战了解ReactNative布局原理
- 增删改查中的-查询
- DIV+CSS布局和Table布局对比
- 解决在matplotlib使用中文的问题
- maven依赖特性
- |BZOJ 1661|暴力|[Usaco2006 Nov]Big Square 巨大正方形
- wifi bluetooth
- centos6.X升级python3.X
- 音频帧的概念
- Android动态权限管理
- SSM的整合
- xml和json的区别比较
- myEclipse项目部署点击Finish按钮没反应
- 微软官方caffe之 matlab接口配置