-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCounting Tilings.cpp
69 lines (62 loc) · 1.59 KB
/
Counting Tilings.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#include<bits/stdc++.h>
#define eb emplace_back
#define ep emplace
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mt make_tuple
#define fi first
#define se second
#define fastio ios::sync_with_stdio(false);cin.tie(NULL)
#define rng_23 mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define DBG(a) cerr<< "line "<<__LINE__ <<" : "<< #a <<" --> "<<(a)<<endl
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int ,int , int > tiii;
const int INF=1e9;
const ll mod=1000000007;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int N = 1024;
vector<int> adj[N];
void solve(){
int n=10,m=1000;
cin>>n>>m;
int hi = 1<<n;
for(int i=0;i<hi;i++){
for(int j=0;j<hi;j++){
if( (i&j) != 0 ) continue;
int emp = 0;
bool pos = true;
for(int k=0;k<n;k++){
if( ((i>>k)&1) == 0 and ((j>>k)&1) == 0 ) emp++;
else{
if( emp%2 == 1 ) pos = false;
emp = 0;
}
}
if( emp%2 == 1 ) pos = false;
if(pos)adj[i].push_back(j);
}
}
ll dp[1025] = {0};
ll prevDp[1025] = {0};
dp[0] = 1;
for(int i=1;i<=m;i++){
for(int j=0;j<hi;j++) {
prevDp[j] = dp[j];
dp[j] = 0;
}
for(int j=0;j<hi;j++){
for(auto k:adj[j]) {
dp[j]+=prevDp[k];
dp[j]%=mod;
}
}
}
cout<<dp[0];
}
int main(){
solve();
}