zoukankan      html  css  js  c++  java
  • hdu 4414 暴力枚举

    #include <cstdio>
    #include <cstring>
    #include <iostream>
    #include <cmath>
    #include <algorithm>
    #include <queue>
    #include <vector>
    using namespace std;
    
    const int maxe = 50000;
    const int maxn = 65;
    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=0;i<N;i++)
                scanf("%s",G[i]);
    
    
            memset(vis,0,sizeof(vis));
            ans = 0;
            for(int i=1;i<N-1;i++)
                for(int j=1;j<N-1;j++){
                    if(G[i][j] == 'o') continue;
                    if(vis[i][j])  continue;
                    for(int len=1;len<=N;len++){
    
                        if( len > 1 &&(i-len<0||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<0)  ){
                            ans ++ ;
                            break;
                        }
                        if(i-len<0 || i+len>=N || j-len<0 || 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-1]=='#' || G[i-len][j+1]=='#')  break;
                        if(G[i+len][j-1]=='#' || G[i+len][j+1]=='#')  break;
                        if(G[i-1][j-len]=='#' || G[i+1][j-len]=='#')  break;
                        if(G[i-1][j+len]=='#' || G[i+1][j+len]=='#')  break;
                        vis[i-len][j] = vis[i+len][j] = true;
                        vis[i][j-len] = vis[i][j+len] = true;
                    }
    
            }
            printf("%d
    ",ans);
        }
    }
    View Code
  • 相关阅读:
    活动识别API服务开发
    定位服务API案例
    高精地图定位
    HiCar SDK概述
    HiCar人-车-家全场景智慧互联
    AIoT开放平台及应用
    AI+IoT+电池应用
    智能物联网(AIoT,2020年)(下)
    第一课
    分销
  • 原文地址:https://www.cnblogs.com/acmdeweilai/p/3307585.html
Copyright © 2011-2022 走看看