思路:dp
dp[i][j]表示经过(i, j) 这个点的方案数
然后一层一层地转移, 对于某一层, 用二进制枚举这一层的连接情况,
判断连接是否符合题意, 然后再进行转移
代码:
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define mem(a, b) memset(a, b, sizeof(a))
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fopen freopen("in.txt", "r", stdin);freopen("out.txt", "w", stout);
//head const int N = , M = ;
const int MOD = 1e9 + ;
int dp[N][M];
int main() {
int h, w, k;
scanf("%d %d %d", &h, &w, &k);
if(w == ) return *puts("");
dp[][] = ;
for (int i = ; i <= h; i++) {
for (int k = ; k < <<(w-); k++) {
bool f = true;
for (int j = ; j < (w-); j++) {
if((k&(<<j)) && (k&(<<j+))) {
f = false;
break;
}
}
if(f) {
for (int j = ; j < w; j++) {
if(j >= && (k&(<<j-))) {
dp[i][j] = (dp[i][j] + dp[i-][j-]) % MOD;
}
else if(j < w- && (k&(<<j))) {
dp[i][j] = (dp[i][j] + dp[i-][j+]) % MOD;
}
else {
dp[i][j] = (dp[i][j] + dp[i-][j]) % MOD;
}
}
}
}
}
printf("%d\n", dp[h][k-]);
return ;
}