题意:

就是给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. mysql和mongodb的区别

    1.mongodb的概括 MongoDB(文档型数据库):提供可扩展的高性能数据存储 2.mongodb的功能概括 (1)基于分布式文件存储 (2)高负载情况下添加更多节点,可以保证服务器性能 (3) ...

  2. UVA-12083 Guardian of Decency 二分图 最大独立集

    题目链接:https://cn.vjudge.net/problem/UVA-12083 题意 学校组织去郊游,选择最多人数,使得任意两个人之间不能谈恋爱 不恋爱条件是高差大于40.同性.喜欢的音乐风 ...

  3. OpenJudge 1031 Lausanne Capitale Olympique

    Lausanne Capitale Olympique Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on  ...

  4. 怎样在windows7上使用snmp命令

    原文地址:http://wenboxz.com/archives/window7-use-snmp-command.html/

  5. hdu3468 Treasure Hunting 二分匹配

    //给一个n*m的图 //.表示空白地 //*表示有黄金 //#表示墙 //一个人须要依照A...Z..a..z的顺序以最短路径走到下一个 //每次仅仅能在他的路线上经过的地方取一块黄金 //问最多能 ...

  6. URL长链接转换为短链接

    URL长链接转换为段链接的工具非常多,可是.小编还是要给大家唠一种方法的: 操作过程例如以下,打开腾讯微博或者其它微,将自己的URL地址值按图片操作:

  7. GetKeyState(), GetAsyncKeystate(), GetKeyboardSlate()

    GetKeyState.GetAsyncKeyState.GetKeyboardState函数的差别: 1.BOOL GetKeyboardState( PBYTE lpKeyState );获得全部 ...

  8. select多选 multiple的使用

    select多选  multiple的使用 <html> <head> <script type="text/javascript"> func ...

  9. HNU13377:Book Club(DFS)

    Problem description Porto's book club is buzzing with excitement for the annual book exchange event! ...

  10. lightoj--1155-- Power Transmission (最大流拆点)

    Power Transmission Time Limit: 2000MS   Memory Limit: 32768KB   64bit IO Format: %lld & %llu Sub ...