BZOJ 1088 [SCOI2005]扫雷Mine

没居前两个格,然后剩下的所有格子情况就确定了~

 

View Code
 1 #include <iostream>
 2 #include <cstdlib>
 3 #include <cstdio>
 4 #include <cstring>
 5 #include <algorithm>
 6 
 7 #define N 11000
 8 
 9 using namespace std;
10 
11 int gs[N],bh[N];
12 int n,ans;
13 
14 inline void read()
15 {
16     scanf("%d",&n);
17     for(int i=1;i<=n;i++) scanf("%d",&gs[i]);
18 }
19 
20 inline void gofor()
21 {
22     for(int i=2,fr;i<=n;i++)
23     {
24         fr=bh[i]+bh[i-1];
25         if(fr==gs[i]) bh[i+1]=0;
26         else if(fr==gs[i]-1) bh[i+1]=1;
27         else return;
28     }
29     if(bh[n+1]==0) ans++;
30 }
31 
32 inline void go()
33 {
34     if(n==1)
35     {
36         if(gs[1]<=1) ans++;
37         return;
38     }
39     for(int i=0;i<=1;i++)
40         for(int j=0;j<=1;j++)
41         {
42             bh[1]=i; bh[2]=j;
43             int tmp=i+j;
44             if(gs[1]!=tmp) continue;
45             gofor();
46         }
47     printf("%d\n",ans);
48 }
49 
50 int main()
51 {
52     read();
53     go();
54     return 0;
55 }

 

 

posted @ 2013-01-18 22:50  proverbs  阅读(...)  评论(... 编辑 收藏