很好的一道题,仔细思索(在y^3 dalao的帮助下)可以发现答案只有0 1 2三种情况

直接枚举第一位有没有雷,就可以递推了qwq

附上y^3大佬的blogs https://blog.csdn.net/Y_Y_Y_3

#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
template<class T>void read(T &x){
int f=0;x=0;char ch=getchar();
while(ch<'0'||ch>'9') {f|=(ch=='-');ch=getchar();}
while(ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
x=f?-x:x;
} const int N=10007;
int a[N],ans[N];
int yyy,n;
bool b[N]; inline bool yhh(bool qwq){
memset(b,0,sizeof(b));
b[1]=qwq;
for(int i=1;i<=n;++i)
if(b[i-1]+b[i]+1==a[i])
b[i+1]=1;
if(b[n+1]) return 0;
for(int i=1;i<=n;++i)
if(b[i-1]+b[i]+b[i+1]!=a[i])
return 0; return 1;
} int main(){
read(n);
for(int i=1;i<=n;++i)
read(a[i]);
if((n==1&&a[1]>1)||(n==2&&a[1]+a[2]>=5)){
printf("0\n");
return 0;
}
printf("%d\n",yhh(1)+yhh(0));
return 0;
}

luogu P2327 [SCOI2005]扫雷的更多相关文章

  1. 【题解】Luogu P2327 [SCOI2005]扫雷

    Luogu P2327 [SCOI2005]扫雷 Description 相信大家都玩过扫雷的游戏.那是在一个n*m的矩阵里面有一些雷,要你根据一些信息找出雷来.万圣节到了,"余" ...

  2. Luogu P2327 [SCOI2005]扫雷【递推/数学】By cellur925

    题目传送门 推了好久啊.看来以后要多玩扫雷了qwq. 其实本题只有三种答案:0.1.2. 对于所有第一列,只要第一个数和第二个数确定后,其实整个数列就确定了,我们可以通过这个递推式得出 sec[i-] ...

  3. 洛谷 P2327 [SCOI2005]扫雷

    P2327 [SCOI2005]扫雷 https://www.luogu.org/problem/show?pid=2327 题目描述 输入输出格式 输入格式: 第一行为N,第二行有N个数,依次为第二 ...

  4. bzoj1088 P2327 [SCOI2005]扫雷

    P2327 [SCOI2005]扫雷 emmmmm.....这题真可以用状压写 因为每个数字只对3个格子有影响,相当于只有2^3=8种状态,所以可以用状压瞎搞 我们用8个数字代表二进制下的8种状态 0 ...

  5. 洛谷P2327 [SCOI2005]扫雷 [2017年5月计划 清北学堂51精英班Day1]

    P2327 [SCOI2005]扫雷 题目描述 输入输出格式 输入格式: 第一行为N,第二行有N个数,依次为第二列的格子中的数.(1<= N <= 10000) 输出格式: 一个数,即第一 ...

  6. P2327 [SCOI2005]扫雷(递推)

    题目链接: https://www.luogu.org/problemnew/show/P2327 题目描述 相信大家都玩过扫雷的游戏.那是在一个$n*m$的矩阵里面有一些雷,要你根据一些信息找出雷来 ...

  7. 洛谷P2327 [SCOI2005] 扫雷

    题目描述 输入输出格式 输入格式: 第一行为N,第二行有N个数,依次为第二列的格子中的数.(1<= N <= 10000) 输出格式: 一个数,即第一列中雷的摆放方案数. 输入输出样例 输 ...

  8. P2327 [SCOI2005]扫雷

    题目描述 输入输出格式 输入格式: 第一行为N,第二行有N个数,依次为第二列的格子中的数.(1<= N <= 10000) 输出格式: 一个数,即第一列中雷的摆放方案数. 输入输出样例 输 ...

  9. 【递推】BZOJ 1088: [SCOI2005]扫雷Mine

    1088: [SCOI2005]扫雷Mine Time Limit: 10 Sec  Memory Limit: 162 MBSubmit: 2275  Solved: 1328[Submit][St ...

随机推荐

  1. url 中文及特殊字符转码

    #include <ctype.h> std::string UrlEncode(const std::string& szToEncode) {    std::string s ...

  2. with(window) onload=onresize=function(){} 写法

    with(window) onload=onresize=function(){} 写法 with的用法: with(对象A) { 语句块 } 语句块中可以直接使用 对象A中的属性和方法 ------ ...

  3. [LeetCode] Short Encoding of Words 单词集的短编码

    Given a list of words, we may encode it by writing a reference string S and a list of indexes A. For ...

  4. [Educational Round 5][Codeforces 616F. Expensive Strings]

    这题调得我心疲力竭...Educational Round 5就过一段时间再发了_(:з」∠)_ 先后找了三份AC代码对拍,结果有两份都会在某些数据上出点问题...这场的数据有点水啊_(:з」∠)_[ ...

  5. BZOJ 1053 - 反素数ant - [数论+DFS][HAOI2007]

    题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1053 题解: 可以证明,$1 \sim N$ 中最大的反质数,就是 $1 \sim N$ ...

  6. js canvas游戏初级demo-躲避障碍物

    在线演示地址 http://200ok.fun:3100/html/game_demo.html 继上次js canvas游戏初级demo-上下左右移动(https://www.cnblogs.com ...

  7. SQL开发——SQL语法

    文档资料参考: 参考:http://www.w3school.com.cn/sql/sql_syntax.asp 参考:http://wiki.jikexueyuan.com/project/sql/ ...

  8. [dev] 中文版内核代码编码规范

    我是我最喜欢的编码规范.并始终坚持. https://www.kernel.org/doc/html/v4.15/translations/zh_CN/coding-style.html

  9. CentOS7安装GitLab服务

    安装GitLab服务 1.安装必要依赖 yum install -y curl policycoreutils openssh-server openssh-clients postfix 2.下载安 ...

  10. net-tools与iproute2

    net-tools与iproute2 我们知道redhat系列发行版7x版本中最小化安装是没有net-tools工具包的,默认使用iproute2工具包,最直观的感受是ifconfig命令被ip命令所 ...