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型的更多相关文章

  1. 敏捷开发松结对编程系列:L型代码结构案例StatusFiltersDropdownList(中)

    这是松结对编程的第22篇(专栏目录). 接前文 业务代码 比较长,基本上就是看被注释隔开的三大段,先显示状态群筛选链接,然后是单个状态筛选,然后是显示下拉框的当前选中项,最后显示下拉框. public ...

  2. hdu 3308 最长连续上升区间

    LCIS Time Limit: 6000/2000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submis ...

  3. hdu 3068 最长回文 manacher算法(视频)

    感悟: 首先我要Orz一下qsc,我在网上很难找到关于acm的教学视频,但偶然发现了这个,感觉做的很好,链接:戳戳戳 感觉这种花费自己时间去教别人的人真的很伟大. manacher算法把所有的回文都变 ...

  4. hdu 3068 最长回文(manachar求最长回文子串)

    题目连接:hdu 3068 最长回文 解题思路:通过manachar算法求最长回文子串,如果用遍历的话绝对超时. #include <stdio.h> #include <strin ...

  5. L型代码结构案例:Link访问权限(上)

    这是松结对编程的第20篇(专栏目录). 本文探讨Link访问权限的最佳实现方法,力求外观干净且封装良好. 这些代码将位于L型代码结构(参见松结对编程系列中的定义)的下层,调用者无需理解其原理. 顺便说 ...

  6. HDU - 3068 最长回文(manacher)

    HDU - 3068 最长回文 Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %I64d & %I64u Subm ...

  7. [数学] 将长为L的木棒随机折成3段,则3段构成三角形的概率

    1.题目 如题,将长为L的木棒随机折成3段,则3段构成三角形的概率是多少? 2.解析 这个与其说是编程题目,倒不如说是个数学题目.可能是你没有见过,或者没有过这种解题思想.(还是那句,一回生两回熟,类 ...

  8. hdu 4691 最长的共同前缀 后缀数组 +lcp+rmq

    http://acm.hdu.edu.cn/showproblem.php? pid=4691 去年夏天,更多的学校的种族称号.当时,没有后缀数组 今天将是,事实上,自己的后缀阵列组合rmq或到,但是 ...

  9. hdu 1950 最长上升子序列(lis) nlogn算法【dp】

    这个博客说的已经很好了.http://blog.csdn.net/shuangde800/article/details/7474903 简单记录一下自己学的: 问题就是求一个数列最长上升子序列的长度 ...

随机推荐

  1. servlet第三篇

    Servlet是一个供其他Java程序(Servlet引擎)调用的Java类,它不能独立运行,它的运行完全由Servlet引擎来控制和调度. 针对客户端的多次Servlet请求,通常情况下,服务器只会 ...

  2. RESTORE 无法处理数据库 'Students',因为它正由此会话使用。建议在执行此操作时使用 master 数据库。

    恢复数据库是总弹出报错对话框如下:RESTORE 无法处理数据库 'Students',因为它正由此会话使用.建议在执行此操作时使用 master 数据库.RESTORE DATABASE 正在异常终 ...

  3. python 刷题必备

    1.判断输入的数字是否是回文数: 学习内容:把数字转成字符串 1. def is_palindrome(n): n=str(n) m=n[::-1] return n==m 2. tmp_str = ...

  4. jquery clone 获取文本框值得问题

    1 clone 出来的文本框 默认不会把原来的事件也带过去 如果使用 $("#").clone(true);   true  可以将原来的事件带过去 获取文本框的值 可以使用事件 ...

  5. RigidBody组件的Is Kinematic

    RigidBody组件的Is Kinematic属性打上勾(设为true,使其不受物理引擎驱动,Wall是为了防止其移动,Person是为了防止其受到力不断旋转—看的心塞=v=) .is kinema ...

  6. Python调shell

    os.system(cmd) 函数返回cmd的结束状态码,阻塞调用. os.popen(cmd) 函数返回cmd的标准输出,阻塞调用. (status, output) = commands.gets ...

  7. [leetcode]415. Add Strings字符串相加

    Given two non-negative integers num1 and num2 represented as string, return the sum of num1 and num2 ...

  8. Loitor_产品(二)校准立体摄像机

    [1]Loitor VI Sensor 可以通过 ROS 自自带的双目相机标定工工具 cameracalibrator.py 来标定相机内参,详细过程http://wiki.ros.org/camer ...

  9. IIS支持IPA、APK文件的下载

    IIS里MIME类型中默认是没有ipa,apk文件的,所以无法直接通过网络下载.   解决方法如下: 1.打开IIS信息服务管理器,选中自已的网站,在右边面板中找到MIME类型. 2.双击打开,点击右 ...

  10. meterpreter 如何留后门,使攻击持久化

    安装后门方法一:meterpreter >run persistence -X -i 5 -p 443 -r 192.168.0.108 Persistent agent script is 6 ...