Topic Link: hdu_5965_ minesweeper
Test instructions
Chinese, or see for yourself.
Exercises
Live game This problem with the pressure DP, but now think about it still really want to complicate, calm down carefully think about, in fact, the first i-1 to determine, then the first I is also OK, can be handed out.
Set Dp[i] to show the number of mines in column I, and then enumerate the number of mines in the first column, you can roll out all the thunder, and then count the contributions.
1#include <bits/stdc++.h>2 #defineF (I,A,B) for (int i=a;i<=b;i++)3 using namespacestd;4 5 Const intn=1e4+7, p=1e8+7;6 7 CharS[n];8 intNum[n],dp[n],t,ans,n;9 Ten intMain () One { Ascanf"%d",&t); - while(t--) - { thescanf"%s", s+1), ans=0; -N=strlen (s+1); - for(intI=1; i<=n;i++) num[i]=s[i]-'0'; -F (I,0, num[1]) + { -dp[1]=i; + if(i>2) Break; A intJ; at for(j=2; j<=n;j++) - { - intnow=num[j-1]-dp[j-1]-dp[j-2]; - if(now>2|| now<0) Break; -dp[j]=Now ; - } in if(j<=n| | dp[n-1]+dp[n]!=num[n])Continue; - intan=1; toF (J,1, N)if(dp[j]==1) an*=2, an%=P; +ans+=an,ans%=P; - } theprintf"%d\n", ans); * } $ return 0;Panax Notoginseng}
View Code
hdu_5965_ Minesweeper (Recursive)