[bzoj1088][SCOI2005]扫雷Mine【乱搞】

【题目链接】
  http://www.lydsy.com/JudgeOnline/problem.php?id=1088
【题解】
  很水的一道题,有很多种解法。
  笔者用的是,枚举最边上两个是不是雷,然后接下来的雷的分布方式就唯一了,按位确定并判断是否可行就行了。

/* --------------
    user Vanisher
    problem bzoj-1088 
----------------*/
# include <bits/stdc++.h>
# define    ll      long long
# define    inf     0x3f3f3f3f
# define    N       10100 
using namespace std;
int read(){
    int tmp=0, fh=1; char ch=getchar();
    while (ch<'0'||ch>'9'){if (ch=='-') fh=-1; ch=getchar();}
    while (ch>='0'&&ch<='9'){tmp=tmp*10+ch-'0'; ch=getchar();}
    return tmp*fh;
}
int n,a[N],b[N],ans;
int doit(){
    for (int i=0; i<=n+1; i++) b[i]=a[i];
    for (int i=1; i<=n; i++){
        if (b[i-1]>0)
            b[i-1]--, b[i]--, b[i+1]--;
    }
    for (int i=0; i<=n+1; i++)
        if (b[i]!=0) return 0;
    return 1;
}
int main(){
    n=read();
    for (int i=1; i<=n; i++)
        a[i]=read();
    a[0]=1; a[n+1]=1; ans+=doit();
    a[0]=1; a[n+1]=0; ans+=doit();
    a[0]=0; a[n+1]=1; ans+=doit();
    a[0]=0; a[n+1]=0; ans+=doit();
    printf("%d\n",ans);
    return 0;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值