hdu 4414 暴力枚举

#include <cstdio>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <vector>
using namespace std; const int maxe = ;
const int maxn = ;
const int INF = 0x3f3f3f; char G[maxn][maxn];
bool vis[maxn][maxn];
int ans;
int N; int main()
{
//freopen("E:\\acm\\input.txt","r",stdin);
while(scanf("%d",&N) && N){
for(int i=;i<N;i++)
scanf("%s",G[i]); memset(vis,,sizeof(vis));
ans = ;
for(int i=;i<N-;i++)
for(int j=;j<N-;j++){
if(G[i][j] == 'o') continue;
if(vis[i][j]) continue;
for(int len=;len<=N;len++){ if( len > &&(i-len<||G[i-len][j]=='o') &&(i+len>=N|| G[i+len][j]=='o')&& (j+len>=N||G[i][j+len]=='o') &&(G[i][j-len]=='o'||j-len<) ){
ans ++ ;
break;
}
if(i-len< || i+len>=N || j-len< || j+len>=N) break;
if(G[i-len][j]=='o') break;
if(G[i+len][j]=='o') break;
if(G[i][j-len]=='o') break;
if(G[i][j+len]=='o') break;
if(G[i-len][j-]=='#' || G[i-len][j+]=='#') break;
if(G[i+len][j-]=='#' || G[i+len][j+]=='#') break;
if(G[i-][j-len]=='#' || G[i+][j-len]=='#') break;
if(G[i-][j+len]=='#' || G[i+][j+len]=='#') break;
vis[i-len][j] = vis[i+len][j] = true;
vis[i][j-len] = vis[i][j+len] = true;
} }
printf("%d\n",ans);
}
}
上一篇:使用Notepad++编码编译时报错(已解决?)


下一篇:python全栈开发-Day5 集合