hdu 5024 最长的L型
http://acm.hdu.edu.cn/showproblem.php?pid=5024
找到一个最长的L型,L可以是斜着的
简单的模拟
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
#define RD(x) scanf("%d",&x)
#define RD2(x,y) scanf("%d%d",&x,&y)
#define clr0(x) memset(x,0,sizeof(x))
int n;
char s[115][115];
bool vis[115][115];
int dx[] = {1,-1,0,0,1,-1,1,-1},
dy[] = {0,0,1,-1,-1,-1,1,1};
bool in(int x,int y)
{
return 0 <= x && x < n && 0 <= y && y < n;
}
int find(int x,int y)
{ int ans = 0;
for(int i = 0;i < 8;++i)
for(int j = i+1;j < 8;++j)if(dx[i]*dx[j] + dy[i]*dy[j] == 0){
int xx = x + dx[i],yy = y + dy[i];
int x1 = x + dx[j],y1 = y + dy[j];
int res = 1;
while(in(xx,yy) && s[xx][yy] == '.'){
res++;
xx += dx[i];
yy += dy[i];
}
while(in(x1,y1) && s[x1][y1] == '.'){
res++;
x1 += dx[j];
y1 += dy[j];
}
ans = max(res,ans);
}
return ans;
}
int main(){
while(~RD(n) && n){
//clr0(vis);
for(int i = 0;i < n;++i){
scanf("%s",s[i]);
}
int mx = 0;
for(int i = 0;i < n;++i)
for(int j = 0;j < n;++j){
if(s[i][j] == '.'){
mx = max(mx,find(i,j));
}
}
printf("%d\n",mx);
}
return 0;
}
hdu 5024 最长的L型的更多相关文章
- 敏捷开发松结对编程系列:L型代码结构案例StatusFiltersDropdownList(中)
这是松结对编程的第22篇(专栏目录). 接前文 业务代码 比较长,基本上就是看被注释隔开的三大段,先显示状态群筛选链接,然后是单个状态筛选,然后是显示下拉框的当前选中项,最后显示下拉框. public ...
- hdu 3308 最长连续上升区间
LCIS Time Limit: 6000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submis ...
- hdu 3068 最长回文 manacher算法(视频)
感悟: 首先我要Orz一下qsc,我在网上很难找到关于acm的教学视频,但偶然发现了这个,感觉做的很好,链接:戳戳戳 感觉这种花费自己时间去教别人的人真的很伟大. manacher算法把所有的回文都变 ...
- hdu 3068 最长回文(manachar求最长回文子串)
题目连接:hdu 3068 最长回文 解题思路:通过manachar算法求最长回文子串,如果用遍历的话绝对超时. #include <stdio.h> #include <strin ...
- L型代码结构案例:Link访问权限(上)
这是松结对编程的第20篇(专栏目录). 本文探讨Link访问权限的最佳实现方法,力求外观干净且封装良好. 这些代码将位于L型代码结构(参见松结对编程系列中的定义)的下层,调用者无需理解其原理. 顺便说 ...
- HDU - 3068 最长回文(manacher)
HDU - 3068 最长回文 Time Limit: 2000MS Memory Limit: 32768KB 64bit IO Format: %I64d & %I64u Subm ...
- [数学] 将长为L的木棒随机折成3段,则3段构成三角形的概率
1.题目 如题,将长为L的木棒随机折成3段,则3段构成三角形的概率是多少? 2.解析 这个与其说是编程题目,倒不如说是个数学题目.可能是你没有见过,或者没有过这种解题思想.(还是那句,一回生两回熟,类 ...
- hdu 4691 最长的共同前缀 后缀数组 +lcp+rmq
http://acm.hdu.edu.cn/showproblem.php? pid=4691 去年夏天,更多的学校的种族称号.当时,没有后缀数组 今天将是,事实上,自己的后缀阵列组合rmq或到,但是 ...
- hdu 1950 最长上升子序列(lis) nlogn算法【dp】
这个博客说的已经很好了.http://blog.csdn.net/shuangde800/article/details/7474903 简单记录一下自己学的: 问题就是求一个数列最长上升子序列的长度 ...
随机推荐
- Javascript 函数传参问题
属于传值,不能改变参数的属性 example 1 function Myvalue(){ var arry = 5; return arry ; } document.getElementById( ...
- LPSN获取菌python脚本
本文转载于https://mp.weixin.qq.com/s?__biz=MzIxNzEzODA5NQ==&mid=2649373408&idx=1&sn=232c2cb36 ...
- sharepoint 调查问卷权限设置
参考网址:http://www.cnblogs.com/mybi/archive/2011/04/18/2019935.html 按文章设置后发现访问时提示没有权限. 于是把新权限(问卷回复)的权限组 ...
- oracle以逗号分隔查询结果列表
select wmsys.wm_concat(id) from table_name where id >= 5000 and id < 6000
- Linux 查看当前时间
一.查看和修改Linux的时区1. 查看当前时区命令 : "date -R"2. 修改设置Linux服务器时区方法 A命令 : "tzselect"方法 B 仅 ...
- maven不存在jar包解决
win7环境 下载:https://maven.apache.org/download.cgi 提取文件,并cmd 转到bin目录 假设要添加的jar包是jbarcode-0.2.8.jar, 可执行 ...
- runloop - 面试题
2.
- ajax请求工具类
ajax的get和post请求工具类: /** * 公共方法类 * * 使用 变量名=function()定义函数时,如果在变量名前加var,则这个变量变成局部变量 */var Common = ...
- 生成静态页html
代码: using System; using System.Collections; using System.Collections.Generic; using System.IO; using ...
- JS如何获取PHP循环中的ID
JS如何获取PHP循环中的ID kaalrz 二路公交车 结帖率:83.33% 首先抱歉,因为昨天那帖图片几次都不能用,修改到不能再次修改,今天早上回帖又提示没有这个帖,只好重发一次. 如 ...