# BZOJ 1088 扫雷Mine 枚举初始状态

https://www.lydsy.com/JudgeOnline/problem.php?id=1088

1 #include<bits/stdc++.h>
2 #define IOS ios::sync_with_stdio(false);//不可再使用scanf printf
3 #define Max(a, b) ((a) > (b) ? (a) : (b))//禁用于函数，会超时
4 #define Min(a, b) ((a) < (b) ? (a) : (b))
5 #define Mem(a) memset(a, 0, sizeof(a))
6 #define Dis(x, y, x1, y1) ((x - x1) * (x - x1) + (y - y1) * (y - y1))
7 #define MID(l, r) ((l) + ((r) - (l)) / 2)
8 #define lson ((o)<<1)
9 #define rson ((o)<<1|1)
10 #define Accepted 0
12 using namespace std;
14 {
15     int x=0,f=1;char ch=getchar();
16     while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
17     while (ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
18     return x*f;
19 }
20
21 typedef long long ll;
22 const int maxn = 10000 + 10;
23 const int MOD = 1000000007;//const引用更快，宏定义也更快
24 const int INF = 1e9 + 7;
25 const double eps = 1e-6;
26 int a[maxn];
27 int f[maxn];//f[i]表示i是否有雷
28 int n;
29 bool judge()
30 {
31     for(int i = 2; i <= n; i++)f[i] = a[i - 1] - f[i - 1] - f[i - 2];
32     for(int i = 1; i <= n; i++)
33     {
34         if(a[i] != f[i - 1] + f[i] + f[i + 1] || f[i] < 0 || f[i] > 2)return false;
35     }
36     return true;
37 }
38 int main()
39 {
40     cin >> n;
41     for(int i = 1; i <= n; i++)scanf("%d", &a[i]);
42     int ans = 0;
43     f[1] = 0;//枚举第一行
44     if(judge())ans++;
45     Mem(f);
46     f[1] = 1;
47     if(judge())ans++;
48     cout<<ans<<endl;
49     return Accepted;
50 }

posted @ 2018-09-21 00:07  _努力努力再努力x  阅读(172)  评论(0编辑  收藏  举报