-
Notifications
You must be signed in to change notification settings - Fork 6
/
toi06_domino.cpp
43 lines (38 loc) · 1 KB
/
toi06_domino.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
#include <bits/stdc++.h>
using namespace std;
#define MOD 1e9 + 7
#define endl '\n'
int main()
{
ios_base::sync_with_stdio(0); cin.tie(0);
int k;
cin >> k;
queue<pair<int,int> > q;
vector<bool> c,visited;
for(int i = 0;i <= k/2;i++)
{
int n = k-(2*i)+i,r = i;
q.push({0,0});
c.resize(n);
visited.assign(1<<(n+1),0);
while(!q.empty())
{
int cd = q.front().first,lv = q.front().second;
int tm = cd,cnt = 0;
q.pop();
for(int j = 0;j < n;j++) c[j] = 0;
while(cd)
{
c[cnt] = cd%2;
cd/=2;
cnt++;
}
if(lv==r){ for(int j = 0;j < n;j++) if(c[j]==0) cout << "--\n"; else cout << "||\n"; cout << "E\n"; }
for(int j = 0;j < n;j++)
{
if(c[j]==0 and !visited[tm+(1<<(j))]) q.push({tm+(1<<(j)),lv+1});
visited[tm+(1<<(j))] = true;
}
}
}
}