题意:

就是给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. + (void)initialize vs 静态构造方法

    在继承体系中,多个子类的引用,父类缺省执行一次: 特殊情况: 1)子类没有实现.调用父类方法: 2)子类显示调用父类: 3)存在分类实现,分类实现覆盖本体. Initializes the class ...

  2. servlet中Session的用法

    ## (1)什么是Session? 服务器端为了保存用户的状态而创建的一个特殊的对象(即session对象).          当浏览器第一次访问服务器时,服务器会创建session对象(该    ...

  3. javascript中实现继承的几种方式

    javascript中实现继承的几种方式 1.借用构造函数实现继承 function Parent1(){ this.name = "parent1" } function Chi ...

  4. PHP SOAP 教程

    一.SoapServer 服务器 1.__construct 作用:创建 SoapServer 对象 用法:__construct ( mixed wsdl [, array options] ) 参 ...

  5. SP687 REPEATS - Repeats(后缀数组)

    一个初步的想法是我们枚举重复子串的长度\(L\).然后跑一遍SA.然后我们枚举一个点\(i\),令他的对应点为\(i+L\),然后求出这两个点的LCP和LCS的长度答案就是这个点的答案就是\((len ...

  6. BZOJ 1355[Baltic2009]Radio Transmission(KMP)

    题意 给你一个字符串,它是由某个字符串不断自我连接形成的. 但是这个字符串是不确定的,现在只想知道它的最短长度是多少. (n<=1000000) 题解 这种求最小循环节的题一般是KMP. 因为有 ...

  7. 队列(Queue)-c实现

    相对而言,队列是比较简单的. 代码还有些warning,我改不动,要找gz帮忙. #include <stdio.h> typedef struct node { int data; st ...

  8. 管理windows自启动程序

    1. 点击开始,在运行程序框中输入msconfig,然后回车. 在弹出的对话框中,点击”启动“选项卡,在启动项目列表中,把不需要的启动项目前面的对号去掉. 然后切换到”服务“选项卡,这里的服务项目列表 ...

  9. 2015 Multi-University Training Contest 4 hdu 5335 Walk Out

    Walk Out Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Su ...

  10. 【试水CAS-4.0.3】第02节_CAS服务端登录页个性化

    完整版见https://jadyer.github.io/2015/07/16/sso-cas-login-diy/ /** * @see ------------------------------ ...