zoukankan      html  css  js  c++  java
  • BZOJ1088 [SCOI2005]扫雷Mine

    Description

      相信大家都玩过扫雷的游戏。那是在一个n*m的矩阵里面有一些雷,要你根据一些信息找出雷来。万圣节到了
    ,“余”人国流行起了一种简单的扫雷游戏,这个游戏规则和扫雷一样,如果某个格子没有雷,那么它里面的数字
    表示和它8连通的格子里面雷的数目。现在棋盘是n×2的,第一列里面某些格子是雷,而第二列没有雷,如下图:
    由于第一列的雷可能有多种方案满足第二列的数的限制,你的任务即根据第二列的信息确定第一列雷有多少种摆放
    方案。

    Input

      第一行为N,第二行有N个数,依次为第二列的格子中的数。(1<= N <= 10000)

    Output

      一个数,即第一列中雷的摆放方案数。

    Sample Input

    2
    1 1

    Sample Output

    2
     
     
    正解:搜索
    解题报告:
      搜索水题
     
     1 //It is made by jump~
     2 #include <iostream>
     3 #include <cstdlib>
     4 #include <cstring>
     5 #include <cstdio>
     6 #include <cmath>
     7 #include <algorithm>
     8 #include <ctime>
     9 #include <vector>
    10 #include <queue>
    11 #include <map>
    12 #include <set>
    13 #ifdef WIN32   
    14 #define OT "%I64d"
    15 #else
    16 #define OT "%lld"
    17 #endif
    18 using namespace std;
    19 typedef long long LL;
    20 const int MAXN = 10011;
    21 int n;
    22 int a[MAXN],c[MAXN];
    23 int ans;
    24 
    25 inline int getint()
    26 {
    27        int w=0,q=0;
    28        char c=getchar();
    29        while((c<'0' || c>'9') && c!='-') c=getchar();
    30        if (c=='-')  q=1, c=getchar();
    31        while (c>='0' && c<='9') w=w*10+c-'0', c=getchar();
    32        return q ? -w : w;
    33 }
    34 
    35 inline void dfs(){
    36     for(int i=2;i<=n;i++) {
    37     c[i+1]=a[i]-c[i-1]-c[i];
    38     if(c[i+1]<0) return ; 
    39     }
    40     if(c[n+1]) return ;
    41     ans++;
    42 }
    43 
    44 inline void work(){
    45     n=getint();
    46     for(int i=1;i<=n;i++)  a[i]=getint();
    47     c[1]=0,c[2]=a[1]-c[1],dfs();
    48     c[1]=1,c[2]=a[1]-c[1]; if(c[2]>=0) dfs();
    49     printf("%d",ans);
    50 }
    51 
    52 int main()
    53 {
    54   work();
    55   return 0;
    56 }
     
  • 相关阅读:
    unity fbx 导出动画
    Unity正交模式摄像机与屏幕适配的方法
    unity3d 代码动态添加,修改BoxCollider2D
    Unity3D 移动摇杆处理
    protobuff 编译注意事项
    sendBroadcast无法接收消息可能原因
    FB相关
    上传速度慢
    CocosCreator与Laya2.0区别
    LayaBox 常用技巧
  • 原文地址:https://www.cnblogs.com/ljh2000-jump/p/5674608.html
Copyright © 2011-2022 走看看