HDU-4414 Finding crosses 水题
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4414
直接暴力判断即可。
//STATUS:C++_AC_15MS_232KB
#include <functional>
#include <algorithm>
#include <iostream>
//#include <ext/rope>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <cstring>
#include <cassert>
#include <cstdio>
#include <string>
#include <vector>
#include <bitset>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <list>
#include <set>
#include <map>
using namespace std;
//using namespace __gnu_cxx;
//define
#define pii pair<int,int>
#define mem(a,b) memset(a,b,sizeof(a))
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define PI acos(-1.0)
//typedef
typedef __int64 LL;
typedef unsigned __int64 ULL;
//const
const int N=;
const int INF=0x3f3f3f3f;
const int MOD=,STA=;
const LL LNF=1LL<<;
const double EPS=1e-;
const double OO=1e15;
const int dx[]={-,,,};
const int dy[]={,,,-};
const int day[]={,,,,,,,,,,,,};
//Daily Use ...
inline int sign(double x){return (x>EPS)-(x<-EPS);}
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T lcm(T a,T b,T d){return a/d*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
template<class T> inline T Min(T a,T b,T c){return min(min(a, b),c);}
template<class T> inline T Max(T a,T b,T c){return max(max(a, b),c);}
template<class T> inline T Min(T a,T b,T c,T d){return min(min(a, b),min(c,d));}
template<class T> inline T Max(T a,T b,T c,T d){return max(max(a, b),max(c,d));}
//End char ma[N][N];
int n; int isok(int x,int y)
{
int i,j,l,r,cnth;
for(l=;y-l>= && ma[x][y-l]=='#';l++){
if(ma[x-][y-l]=='#' || ma[x+][y-l]=='#')return ;
}
for(r=;y+r<n && ma[x][y+r]=='#';r++){
if(ma[x-][y+r]=='#' || ma[x+][y+r]=='#')return ;
}
if(l!=r || l== || r==)return ;
cnth=l;
for(l=;x-l>= && ma[x-l][y]=='#';l++){
if(ma[x-l][y-]=='#' || ma[x-l][y+]=='#')return ;
}
for(r=;x+r<n && ma[x+r][y]=='#';r++){
if(ma[x+r][y-]=='#' || ma[x+r][y+]=='#')return ;
}
if(l!=r || l== || r==)return ;
if(cnth!=l)return ;
return ;
} int main()
{
// freopen("in.txt","r",stdin);
int i,j,cnt;
while(~scanf("%d",&n) && n)
{
for(i=;i<n;i++){
scanf("%s",ma[i]);
}
cnt=;
for(i=;i<n-;i++){
for(j=;j<n-;j++){
if(ma[i][j]=='#')cnt+=isok(i,j);
}
} printf("%d\n",cnt);
}
return ;
}
HDU-4414 Finding crosses 水题的更多相关文章
- hdu 4414 Finding crosses【简单模拟】
题目:http://acm.hdu.edu.cn/showproblem.php?pid=4414 CSUST:点击打开链接 Finding crosses Time Limit: 2000/1000 ...
- hdu 4414 Finding crosses
题目链接:hdu 4414 其实是一道简单的字符型水题,不涉及任何算法,可比赛时却没能做出来,这几天的状态都差到家了... 题目大意是求有多少个满足条件的十字架,十字架的边不能有分叉路口,所以枚举每个 ...
- HDU 4414 Finding crosses(dfs)
Problem Description The Nazca Lines are a series of ancient geoglyphs located in the Nazca Desert in ...
- HDU 4414 Finding crosses (DFS + BFS)
题意:在N*N的图中,找出孤立存在的十字架的个数.十字架要求为正十字,孤立表示组成十字架的‘#的周围的一格再无’#‘. dfs找出在中心的‘#’(周围四格也为‘#'),则缩小了搜索范围,再bfs找出是 ...
- hdu 1106:排序(水题,字符串处理 + 排序)
排序 Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submissi ...
- HDU 4950 Monster (水题)
Monster 题目链接: http://acm.hust.edu.cn/vjudge/contest/123554#problem/I Description Teacher Mai has a k ...
- HDU 4813 Hard Code 水题
Hard Code Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...
- HDU 4593 H - Robot 水题
H - RobotTime Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/contest/view.act ...
- HDOJ/HDU 2560 Buildings(嗯~水题)
Problem Description We divide the HZNU Campus into N*M grids. As you can see from the picture below, ...
随机推荐
- Codeforces 612E - Square Root of Permutation
E. Square Root of Permutation A permutation of length n is an array containing each integer from 1 t ...
- Qt 5 常见错误汇总
1.没加 QT+=sql,需要再.pro文件中加上 2.无故崩溃,这个有多种原因,多为指针问题,例如,指针内存泄露,指针未开辟空间直接使用,UI还未建立就使用UI里面的东西..等等 3.Sql问题,有 ...
- java线程池的使用与详解
java线程池的使用与详解 [转载]本文转载自两篇博文: 1.Java并发编程:线程池的使用:http://www.cnblogs.com/dolphin0520/p/3932921.html ...
- boost 编译
备份一下,用的时候直接粘贴,免得到处找>_< 32 bjam threading=multi link=static runtime-link=static --stagedir=stag ...
- 华为机试题——数组排序,且奇数存在奇数位置,偶数存在偶数位置
题目要求很简单,就是给你一个数组,对它进行排序,并且排序后,奇数要放在奇数的位置上,偶数要放在偶数的位置上,如果不满足这个规则的话就在数组上填充0 实现代码如下,文中值得注意的一点就是如何判读这个数字 ...
- Codeforces Round #210
A:简单题: #include<cstdio> using namespace std; int n,k; int main() { scanf("%d%d",& ...
- win7系统64位eclipse环境超详细暗黑1.4服务器搭建
原地址:http://bbs.gameres.com/thread_223704.html 今天闲来没事,参照论坛中几篇成功案例,自己也搭建了下服务端,这里详细的记录下我的安装过程,方便大家快速搭建. ...
- StatsD!次世代系统监控的核心
在互联网业务蒸蒸日上的今时今日,系统架构日渐复杂,随着软件产品和工程团队的变革,许多开源的监控工具应运而生,其中有一些相当出名,比如 Zabbix.Nagios 还有 StatsD.也有一些问题被大家 ...
- 8. Unity异常警告错误处理方法
一. The AnimationClip 'cube1_anim' used by the Animation component 'Cube1' must be marked as Legacy. ...
- 【转】【教程】实现Virtualbox中的XP虚拟机和主机Win7之间的共享文件夹
原文网址:http://www.crifan.com/add_share_folder_for_virtualbox_guest_xp_and_host_win7/ 已经实现了在主机Win7下,在Vi ...