bnuoj 33656 J. C.S.I.: P15(图形搜索题)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=33656
【题解】:暴力搜索题
【code】:
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <queue> using namespace std; char map[][];
int vis[][];
int n,m;
int B,F;
int cx[]={,-,,-,,-,,};
int cy[]={,,,-,-,,-,}; int isAllDog(int l,int r)
{
int i=l-,j=r-;
if(i>=&&j>=)
{
if(map[i][j]!='.') return ;
}
i=l-,j=r;
if(i>=)
{
for(;j<r+;j++)
{
if(map[i][j]!='.') return ;
}
}
i=l-,j=r+;
if(i>=&&j<m)
{
if(map[i][j]!='.') return ;
}
i=l,j=r-;
if(j>=)
{
if(map[i][j]!='.') return ;
}
i=l,j=r+;
if(j<m)
{
if(map[i][j]!='.') return ;
}
i=l+,j=r-;
if(i<n&&j>=)
{
if(map[i][j]!='.') return ;
}
i=l+,j=r;
if(i<n)
{
for(;j<r+;j++)
{
if(map[i][j]!='.') return ;
}
}
i=l+,j=r+;
if(i<n&&j<m)
{
if(map[i][j]!='.') return ;
}
return ;
} void seach_birds()
{
int i,j;
for(i=;i<n;i++)
{
for(j=;j<m-;j++)
{
if(map[i][j]=='/'&&map[i][j+]=='\\'&&map[i][j+]=='/'&&map[i][j+]=='\\')
{
if(isAllDog(i,j))
{
B++;
}
j+=;
}
}
}
} void seach_flower(int x,int y)
{
int i;
vis[x][y] = ;
for(i=;i<;i++)
{
int dx = x+cx[i];
int dy = y+cy[i];
if(dx>=&&dx<n&&dy>=&&dy<m&&!vis[dx][dy]&&map[dx][dy]!='.'&&map[dx][dy]!='=')
{
vis[dx][dy]=;
seach_flower(dx,dy);
}
}
} int main()
{
int t;
scanf("%d",&t);
while(t--)
{ scanf("%d%d",&n,&m);
int i;
for(i=;i<n;i++)
{
scanf("%s",map[i]);
}
B=F=;
seach_birds();
memset(vis,,sizeof(vis));
for(i=;i<m;i++)
{
if(n->=&&map[n-][i]!='.'&&vis[n-][i]==)
{
seach_flower(n-,i);
F++;
}
}
printf("Flowers: %d\n",F);
printf("Birds: %d\n",B); // cout<<B<<endl;
}
return ;
}
bnuoj 33656 J. C.S.I.: P15(图形搜索题)的更多相关文章
- 【数位DP】bnuoj 52813 J. Deciphering Oracles
http://acm.bnu.edu.cn/v3/contest_show.php?cid=9208#problem/J [AC] #include<bits/stdc++.h> usin ...
- 【第一部分】01Leetcode刷题
一.二叉树的中序遍历 题目:94. 二叉树的中序遍历.94. Binary Tree Inorder Traversal 解法一: class Solution { public: vector< ...
- C语言打印图形
//输出图形 * * * * * * * * * * * * * * * * * * * * * * * * * //每行5个* void test1(){ // 外层负责行,外层执行一次,内层 ...
- Java如何利用for循环在控制台输出正方形对角线图形
1 /* 2 利用循环在控制台输出如下正方形对角线图形 3 * * * * * * * * * * * 4 * * * * 5 * * * * 6 * * * * 7 * * * * 8 * * * ...
- bnuoj 4187 GCC (数论)
http://www.bnuoj.com/bnuoj/problem_show.php?pid=4187 [题意]:如题 [题解]:取n,m的最小值进行遍历就可以了: 注意 0 1 这组测试数据 [c ...
- 【codeforces.com/gym/100240 J】
http://codeforces.com/gym/100240 J [分析] 这题我搞了好久才搞出样例的11.76....[期望没学好 然后好不容易弄成分数形式.然后我‘+’没打..[于是爆0... ...
- Codeforces Gym101606 J.Just A Minim (2017 United Kingdom and Ireland Programming Contest (UKIEPC 2017))
J Just A Minim 超级无敌大水题,但是被精度卡了一手,输出要精确到小数点后6位,我直接输出的... 代码: 1 #include<iostream> 2 #include< ...
- [游记]CSP 2021 J/S
这一次,也许是我的OI生涯的转折点了--能过,学习OI的时间就不会减少:但不能过,就会减少学习OI的时间-- 上午(S组) 6:00起床.去吃早餐,结果因为边喝粥边喝牛奶导致肚子疼.(我在这里劝大家, ...
- 2016年江西理工大学C语言程序设计竞赛(初级组)
问题 A: 木棒根数 解法:把所有的情况保存下来,加一下就好 #include<bits/stdc++.h> using namespace std; map<char,int> ...
随机推荐
- Win7如何快速修复系统
Windows 7可能是微软迄 今为止最好的桌面操作系统,但是偶尔出现一些问题还是在所难免的.这里教你如何快速修复出现问题的Windows 7系统,每个操作系统都有重新安装的可能,Windows 7也 ...
- html DOM 变化 通知,很好很强大
刚做一个项目,某个div标签显示后 需要接收一个事件,用于主动调用 window.resize(): 从网上找了了,发现 MutationObserver.给开发者们提供了一种能在某个范围内的DOM树 ...
- Incorporating ASP.NET MVC and SQL Server Reporting Services, Part 1
Your ASP.NET MVC application needs reports. What do you do? In this article, I will demonstrate how ...
- Swiper之滑块1
之前介绍过Swiper,它是一个神奇的插件.类似于Android的触屏操作,Swiper应用于Web中也可以实现这样的效果,我们来看看(用鼠标可拖动). startSlide Integer (def ...
- SQL Server 2008数据库同步配置
以下内容转载于网络,个人做了简单的修改. 数据库同步可以是同一个服务器之间不同数据库之间数据同步,也可以是局域网内不同服务器间数据库的同步. 下面具体说一下步骤,首先我们说一下发布服 ...
- Zend studio 12.5.1安装aptana
aptana是zend studio的一个插件.解决zend对于前台html支持,加亮的问题. 安装方法其实很简单 ,直接给出aptana的地址了. http://download.aptana.co ...
- Pure-ftpd无法连接到服务器 425错误
今天是五一假期的前一天,闲来没事,打开自己的博客,发现很久没有备份数据了,由于工作方面的原因,自己慢慢的退出了技术界,但本人还是依然向往技术界啊!各位技术宅们,加油! 问题发现 当我打开FTP客户端软 ...
- OC5_@class关键字
// // ClassB.h // OC5_@class关键字 // // Created by zhangxueming on 15/6/24. // Copyright (c) 2015年 zha ...
- MTD技术介绍
MTD(Memory Technology device)是用于访问memory设备(ROM.Flash)的Linux子系统,在Linux中引入这一层的主要目的是为了更加简单的添加新的Memory存储 ...
- JS事件冒泡与捕获
1事件传播——冒泡与捕获 默认情况下,事件使用冒泡事件流,不使用捕获事件流.然而,在Firefox和Safari里,你可以显式的指定使用捕获事件流,方法是在注册事件时传入useCapture参数,将这 ...