题意:

就是给12种图形,旋转,翻折。有多少种方法构成n*m=60的矩形

思路:

裸的精确覆盖。就是建图麻烦

个人太挫,直接手写每一个图形的各种形态

须要注意的是最后的答案须要除以4

代码:

#include"stdio.h"
#include"algorithm"
#include"string.h"
#include"iostream"
#include"queue"
#include"map"
#include"vector"
#include"string"
using namespace std;
/*int mp[63][5][5]=
{
{
//1.1
{1,0,0},
{1,0,0},
{1,1,1},
},
{
//1.2
{1,1,1},
{0,0,1},
{0,0,1},
},
{
//1.3
{0,0,1},
{0,0,1},
{1,1,1},
},
{
//1.4
{1,1,1},
{1,0,0},
{1,0,0},
},
{
//2.5
{1,1,1,1,1},
},
{
//2.6
{1},
{1},
{1},
{1},
{1},
},
{
//3.7
{0,1,0},
{1,1,1},
{0,1,0},
},
{
//4.8
{1,1,1},
{1,0,1},
},
{
//4.9
{1,0,1},
{1,1,1},
},
{
//4.10
{1,1},
{1,0},
{1,1},
},
{
//4.11
{1,1},
{0,1},
{1,1},
},
{
//5.12
{1,1,1,1},
{1,0,0,0},
},
{
//5.13
{1,0},
{1,0},
{1,0},
{1,1},
},
{
//5.14
{0,0,0,1},
{1,1,1,1},
},
{
//5.15
{1,1},
{0,1},
{0,1},
{0,1},
},
{
//5.16
{1,0,0,0},
{1,1,1,1},
},
{
//5.17
{0,1},
{0,1},
{0,1},
{1,1},
},
{
//5.18
{1,1,1,1},
{0,0,0,1},
},
{
//5.19
{1,1},
{1,0},
{1,0},
{1,0},
},
{
//6.20
{1,0,0},
{1,1,0},
{0,1,1},
},
{
//6.21
{0,0,1},
{0,1,1},
{1,1,0},
},
{
//6.22
{1,1,0},
{0,1,1},
{0,0,1},
},
{
//6.23
{0,1,1},
{1,1,0},
{1,0,0},
},
{
//7.24
{1,1,1,1},
{0,1,0,0},
},
{
//7.25
{1,0},
{1,0},
{1,1},
{1,0},
},
{
//7.26
{0,0,1,0},
{1,1,1,1},
},
{
//7.27
{0,1},
{1,1},
{0,1},
{0,1},
},
{
//7.28
{0,1,0,0},
{1,1,1,1},
},
{
//7.29
{0,1},
{0,1},
{1,1},
{0,1},
},
{
//7.30
{1,1,1,1},
{0,0,1,0},
},
{
//7.31
{1,0},
{1,1},
{1,0},
{1,0},
},
{
//8.32
{0,0,1},
{1,1,1},
{1,0,0},
},
{
//8.33
{1,1,0},
{0,1,0},
{0,1,1},
},
{
//8.34
{1,0,0},
{1,1,1},
{0,0,1},
},
{
//8.35
{0,1,1},
{0,1,0},
{1,1,0},
},
{
//9.36
{0,1,0},
{0,1,1},
{1,1,0},
},
{
//9.37
{0,1,0},
{1,1,1},
{0,0,1},
},
{
//9.38
{0,1,1},
{1,1,0},
{0,1,0},
},
{
//9.39
{1,0,0},
{1,1,1},
{0,1,0},
},
{
//9.40
{1,1,0},
{0,1,1},
{0,1,0},
},
{
//9.41
{0,1,0},
{1,1,1},
{1,0,0},
},
{
//9.42
{0,1,0},
{1,1,0},
{0,1,1},
},
{
//9.43
{0,0,1},
{1,1,1},
{0,1,0},
},
{
//10.44
{0,1,0},
{0,1,0},
{1,1,1},
},
{
//10.45
{1,1,1},
{0,1,0},
{0,1,0},
},
{
//10.46
{0,0,1},
{1,1,1},
{0,0,1},
},
{
//10.47
{1,0,0},
{1,1,1},
{1,0,0},
},
{
//11.48
{0,1,1},
{1,1,1},
},
{
//11.49
{1,1},
{1,1},
{0,1},
},
{
//11.50
{1,1,1},
{1,1,0},
},
{
//11.51
{1,0},
{1,1},
{1,1},
},
{
//11.52
{1,1,1},
{0,1,1},
},
{
//11.53
{1,1},
{1,1},
{1,0},
},
{
//11.54
{1,1,0},
{1,1,1},
},
{
//11.55
{0,1},
{1,1},
{1,1},
},
{
//12.56
{0,1,1,1},
{1,1,0,0},
},
{
//12.57
{1,0},
{1,0},
{1,1},
{0,1},
},
{
//12.58
{0,0,1,1},
{1,1,1,0},
},
{
//12.59
{1,0},
{1,1},
{0,1},
{0,1},
},
{
//12.60
{1,1,1,0},
{0,0,1,1},
},
{
//12.61
{0,1},
{1,1},
{1,0},
{1,0},
},
{
//12.62
{1,1,0,0},
{0,1,1,1},
},
{
//12.63
{0,1},
{0,1},
{1,1},
{1,0},
},
};
//a代表每一个的行,b代表每一个的列。c代表每一个属于哪种
int a[]= {3,3,3,3,1,5,3,2,2,3,3,2,4,2,4,2,4,2,4,3,3,3,3,2,4,2,4,2,4,2,4,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,2,3,2,3,2,4,2,4,2,4,2,4};
int b[]= {3,3,3,3,5,1,3,3,3,2,2,4,2,4,2,4,2,4,2,3,3,3,3,4,2,4,2,4,2,4,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,2,3,2,3,2,3,2,4,2,4,2,4,2,4,2};
int c[]= {1,1,1,1,2,2,3,4,4,4,4,5,5,5,5,5,5,5,5,6,6,6,6,7,7,7,7,7,7,7,7,8,8,8,8,9,9,9,9,9,9,9,9,10,10,10,10,11,11,11,11,11,11,11,11,12,12,12,12,12,12,12,12};
#define N 63*66*(60+66+14)
#define M 63*66
int ooo,haha;
struct DLX
{
int n,m,C;
int U[N],D[N],L[N],R[N],Row[N],Col[N];
int H[M],S[M],cnt,ans[M];
void init(int _n,int _m)
{
n=_n;
m=_m;
for(int i=0; i<=m; i++)
{
U[i]=D[i]=i;
L[i]=(i==0?m:i-1);
R[i]=(i==m? 0:i+1);
S[i]=0;
}
C=m;
for(int i=1; i<=n; i++) H[i]=-1;
}
void link(int x,int y)
{
C++;
Row[C]=x;
Col[C]=y;
S[y]++;
U[C]=U[y];
D[C]=y;
D[U[y]]=C;
U[y]=C;
if(H[x]==-1) H[x]=L[C]=R[C]=C;
else
{
L[C]=L[H[x]];
R[C]=H[x];
R[L[H[x]]]=C;
L[H[x]]=C;
}
}
void del(int x)
{
R[L[x]]=R[x];
L[R[x]]=L[x];
for(int i=D[x]; i!=x; i=D[i])
{
for(int j=R[i]; j!=i; j=R[j])
{
U[D[j]]=U[j];
D[U[j]]=D[j];
S[Col[j]]--;
}
}
}
void rec(int x)
{
for(int i=U[x]; i!=x; i=U[i])
{
for(int j=L[i]; j!=i; j=L[j])
{
U[D[j]]=j;
D[U[j]]=j;
S[Col[j]]++;
}
}
R[L[x]]=x;
L[R[x]]=x;
}
void dance(int x)
{
if(R[0]==0 || R[0]>ooo)
{
haha++;
//cnt=x;
return ;
}
int now=R[0];
for(int i=R[0]; i!=0 && i<=ooo; i=R[i])
{
if(S[i]<S[now]) now=i;
}
del(now);
for(int i=D[now]; i!=now; i=D[i])
{
//ans[x]=Row[i];
for(int j=R[i]; j!=i; j=R[j]) del(Col[j]);
dance(x+1);
for(int j=L[i]; j!=i; j=L[j]) rec(Col[j]);
}
rec(now);
return ;
}
} dlx;
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=-1)
{
int cnt=0;
ooo=60;
dlx.init(63*60*5,60+12);
for(int i=0; i<63; i++)
{
for(int xx=1; xx+a[i]<=n+1; xx++)
{
for(int yy=1; yy+b[i]<=m+1; yy++)
{
cnt++;
// if(c[i]<5) printf("%d:",c[i]);
for(int x=0; x<a[i]; x++)
{
for(int y=0; y<b[i]; y++)
{
if(mp[i][x][y]==1)
{
int tep=(xx+x-1)*m+(yy+y);
// if(c[i]<5)printf("%d ",tep);
dlx.link(cnt,tep);
}
}
}
//if(c[i]<5) puts("");
dlx.link(cnt,60+c[i]);
}
}
} haha=0;
dlx.dance(0);
printf("%d\n",haha);
}
return 0;
}*/
int ans[]={0,0,0,2,368,1010,2339};
int main()
{
int n,m;
while(scanf("%d%d",&n,&m)!=-1)
{
if(n>m) swap(n,m);
printf("%d\n",ans[n]);
}
return 0;
}

[DLX精确覆盖+打表] hdu 2518 Dominoes的更多相关文章

  1. DLX精确覆盖与重复覆盖模板题

    hihoCoder #1317 : 搜索四·跳舞链 原题地址:http://hihocoder.com/problemset/problem/1317 时间限制:10000ms 单点时限:1000ms ...

  2. 【转】DLX 精确覆盖 重复覆盖

    问题描述: 给定一个n*m的矩阵,有些位置为1,有些位置为0.如果G[i][j]==1则说明i行可以覆盖j列. Problem: 1)选定最少的行,使得每列有且仅有一个1. 2)选定最少的行,使得每列 ...

  3. POJ 3076 Sudoku DLX精确覆盖

    DLX精确覆盖模具称号..... Sudoku Time Limit: 10000MS   Memory Limit: 65536K Total Submissions: 4416   Accepte ...

  4. (简单) POJ 3074 Sudoku, DLX+精确覆盖。

    Description In the game of Sudoku, you are given a large 9 × 9 grid divided into smaller 3 × 3 subgr ...

  5. (简单) HUST 1017 Exact cover , DLX+精确覆盖。

    Description There is an N*M matrix with only 0s and 1s, (1 <= N,M <= 1000). An exact cover is ...

  6. poj3074 DLX精确覆盖

    题意:解数独 分析: 完整的数独有四个充要条件: 1.每个格子都有填数字 2.每列都有1~9中的每个数字 3.每行都有1~9中的每个数字 4.每个9宫格都有1~9中的每个数字 可以转化成精确覆盖问题. ...

  7. POJ 3074 Sudoku DLX精确覆盖

    DLX精确覆盖.....模版题 Sudoku Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 8336   Accepted: ...

  8. [DLX精确覆盖] hdu 1603 A Puzzling Problem

    题意: 给你n块碎片,这些碎片不能旋转.翻折. 问你能不能用当中的某些块拼出4*4的正方形. 思路: 精确覆盖裸题了 建图就是看看每一个碎片在4*4中能放哪些位置,这个就作为行. 列就是4*4=16个 ...

  9. [DLX精确覆盖] hdu 3663 Power Stations

    题意: 给你n.m.d,代表有n个城市.m条城市之间的关系,每一个城市要在日后d天内都有电. 对于每一个城市,都有一个发电站,每一个发电站能够在[a,b]的每一个连续子区间内发电. x城市发电了.他相 ...

随机推荐

  1. BZOJ 3261 最大异或和 (可持久化01Trie)

    题目大意:让你维护一个序列,支持在序列末插入一个数,支持询问$[l,r]$区间内选择一个位置$p$,使$xor\sum_{i=p}^{n}a_{i}$最大 可持久化$01Trie$裸题,把 区间异或和 ...

  2. libcudnn (R5) not found in library path

    环境:Ubuntu 18.04 +  Torch7 + cuda10 在运行使用cudnn的lua程序的时候产生错误: /home/majiabiao/torch/: /home/majiabiao/ ...

  3. Keepalived原理及VRRP协议与应用配置(详细)

    转载自:https://blog.csdn.net/u010391029/article/details/48311699 1. 前言 VRRP(Virtual Router Redundancy P ...

  4. 1.1 Python for macOS 安装与配置

    本文主要讲解在macOS系统下的Python3.7.0的配置与安装问题 并调试好开发环境 目标是编辑成功第一个python程序 下载最新版(3.7.0)Python macOS系统自带python 不 ...

  5. BNUOJ34980方(芳)格(哥)取数(好坑)

    方(芳)格(哥)取数 Time Limit: 3000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java class n ...

  6. UVA 11020 - Efficient Solutions(set)

    UVA 11020 - Efficient Solutions 题目链接 题意:每个人有两个属性值(x, y).对于每个人(x,y)而言,当有还有一个人(x', y'),假设他们的属性值满足x' &l ...

  7. Cms WebSite 编译非常慢

    第一次编译非常慢 如果遇到错误,中途中断的话. 下一次编译的时候,上一次已经编译过的文件,会非常快的略过.很快就会到上一次遇到错误的地方,继续往下进行编译.

  8. PHPStorm打开文件所在目录

    很实用~

  9. Wow C++11

    什么是C++11? 一句话C++11是最新的C++标准,在2011年发布,所以叫C++11.在新的标准出现前,我们一直在用的是C++98,可想而知这份标准是1998年发布的,之后再2003年最过小的修 ...

  10. 数据库表的连接(Left join , Right Join, Inner Join)用法详解

    转自:http://blog.csdn.net/jetjetlinuxsystem/article/details/6663218 Left Join, Inner Join 的相关内容,非常实用,对 ...