【链接】 我是链接,点我呀:)

【题意】

在这里输入题意

【题解】

借鉴网上的题解的。
思路是。
用"标准化"的思想。
确定基准点(0,0)
然后假设(0,0)是第一个连通块。
然后通过大小为1的连通块(0,0)得到所有大小为2的连通块。
然后得到所有大小为3的连通块。。
以此类推
这样可以避免回溯的过程。
直接递推就好。
然后判重。
就是
(标准化->旋转)[4]
以及
翻转-> (标准化->旋转)[4]
()[x]表示括号内的过程重复4次
看看每一种是不是都不存在。
不存在的话,就说明找到了一种新的n+1连通块。

标准化就是每个点的x减去minx,每个点的y减去miny;

旋转则是每个点由{x,y}->{y,-x} (记住就好)

对称则是{x,y]->{x,-y}

每次做完操作之后都要重新标准化。

用set记录所有点的坐标既可。

每次从set中取出点,往外尝试扩展。变成n+1连通块。

(不必有范围的限制)

一开始陷入误区了。

想着每次(n,m)都重新dfs一遍。

其实不必。

我们这样处理出所有的连通块之后。

只要判断一下每个联通块是不是在相应的区域里面就好了。

在的话就递增答案。

【代码】

/*
1.Shoud it use long long ?
2.Have you ever test several sample(at least therr) yourself?
3.Can you promise that the solution is right? At least,the main ideal
4.use the puts("") or putchar() or printf and such things?
5.init the used array or any value?
6.use error MAX_VALUE?
7.use scanf instead of cin/cout?
8.whatch out the detail input require
*/
#include <bits/stdc++.h>
using namespace std; typedef pair<int,int> pii; const int N = 10;
const int dx[4] = {0,0,1,-1};
const int dy[4] = {1,-1,0,0}; int len,n,m;
set<set<pii> > dic[N+10];
set <pii> myset;
int ans[N+5][N+5][N+5]; set <pii> biaozhun(set<pii> now){
int dx = 1e8,dy = 1e8;
for (auto temp:now){
dx = min(dx,temp.first);
dy = min(dy,temp.second);
}
set <pii> temp;
for (auto temp1:now){
temp.insert({temp1.first-dx,temp1.second-dy});
}
return temp;
} set <pii> Rotate(set<pii> now){
set<pii> temp1;temp1.clear();
for (auto temp2:now) temp1.insert({temp2.second,-temp2.first});
return temp1;
} set <pii> Mirror(set<pii> now){
set<pii> temp1;temp1.clear();
for (auto temp2:now) temp1.insert({temp2.first,-temp2.second});
return temp1;
} void in(int dep,set<pii> now){
set <pii> temp1 = now;
for (int i = 1;i <= 4;i++){
temp1 = biaozhun(temp1);
if (dic[dep].count(temp1)>0) return;
temp1 = Rotate(temp1);
}
temp1 = biaozhun(temp1);
temp1 = Mirror(temp1);
for (int i = 1;i <= 4;i++){
temp1 = biaozhun(temp1);
if (dic[dep].count(temp1)>0) return;
temp1 = Rotate(temp1);
}
temp1 = biaozhun(temp1);
dic[dep].insert(temp1);
} int main(){
#ifdef LOCAL_DEFINE
freopen("rush_in.txt", "r", stdin);
#endif
ios::sync_with_stdio(0),cin.tie(0);
set<pii> temp1;temp1.clear();
temp1.insert({0,0}); dic[1].insert(temp1);
for (int i = 1;i <= N-1;i++){
for (auto temp:dic[i]){
//temp是大小为i的一个连通块
for (auto cell:temp){
for (int j = 0;j < 4;j++){
int tx = cell.first + dx[j],ty = cell.second + dy[j];
if (temp.count({tx,ty})==0){
auto temp2 = temp;
temp2.insert({tx,ty});//生成一个新的连通块
in(i+1,temp2);//看看temp2这个连通块有没有重复。
}
}
}
}
} for (int k = 1;k <= 10;k++)
for (int n = 1;n <= 10;n++)
for (int m = 1;m <= 10;m++){
for (auto temp:dic[k]){
int maxx = -100,maxy = -100;
for (auto cell:temp){
maxx = max(maxx,cell.first);
maxy = max(maxy,cell.second);
}
if (min(maxx,maxy)<min(n,m) && max(maxx,maxy)<max(n,m)){
ans[k][n][m]++;
}
}
}
int k,n,m;
while (cin >>k>>n>>m){
cout << ans[k][n][m]<<endl;
}
return 0;
}

【例题 7-14 UVA-1602】Lattice Animals的更多相关文章

  1. UVA - 1602 Lattice Animals (暴力+同构判定)

    题目链接 题意:求能放进w*h的网格中的不同的n连通块个数(通过平移/旋转/翻转后相同的算同一种),1<=n<=10,1<=w,h<=n. 刘汝佳的题真是一道比一道让人自闭.. ...

  2. UVA 1602 Lattice Animals

    题目 输入n.w.h($1\leqslant n \leqslant 10, 1\leqslant w,h \leqslant n$),求能放在w*h网格里的不同的n连块的个数(注意,平移.旋转.翻转 ...

  3. UVa 1602 Lattice Animals (STL && 生成n连块 && 无方向形状判重)

    题意 : 给定一个 w * h 的 矩阵,在矩阵中找不同n个连通块的个数(旋转,翻转,平移算作一种) 分析 : 这题的关键点有两个 ① 生成n连块并且存储起来(因为题目是多测试用例,如果每一次都重新生 ...

  4. 【DFS】【打表】Lattice Animals

    [ZOJ2669]Lattice Animals Time Limit: 5 Seconds      Memory Limit: 32768 KB Lattice animal is a set o ...

  5. UVA 11768 - Lattice Point or Not(数论)

    UVA 11768 - Lattice Point or Not option=com_onlinejudge&Itemid=8&page=show_problem&categ ...

  6. 紫书 例题7-14 UVa 1602(搜索+STL+打表)

    这道题想了很久不知道怎么设置状态,怎么拓展,怎么判重, 最后看了这哥们的博客 终于明白了. https://blog.csdn.net/u014800748/article/details/47400 ...

  7. UVA-1602 Lattice Animals 搜索问题(打表+set)

    题目链接 https://vjudge.net/problem/UVA-1602 紫书的一道例题,跟之前的很多题目有很多不同. 本题不像是一般的dfs或bfs这样的搜索套路,而是另一种枚举思路. 题意 ...

  8. UVA 11768 Lattice Point or Not(扩展欧几里德)

    将直线转化为ax + by = c的形式,然后扩展欧几里得求在[x1, x2]之间的解 对直线与坐标轴平行的特判 调试了好长时间,注意: 1 正负数转化为整型的处理 2 注意判断有无解 #includ ...

  9. 【POJ】2170 Lattice Animals

    1. 题目描述给定$n \times m, n.m \in [1, 10]$的方格,求不同形状的$[1 \cdots 10]$联通块的个数?所谓不同形状,表示不能通过平移.旋转.镜像实现相同的形状.2 ...

随机推荐

  1. PPAPI中使用Chromium的3D图形接口

    使用PPAPI的Graphics 3D接口做了一个小演示样例,鼠标点击插件区域.绘制颜色,效果与ppapi_simple相似. foruok原创,如需转载请关注foruok的微信订阅号"程序 ...

  2. vue5 过滤器 模版

    <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...

  3. azkaban(安装配置加实战)

    为什么需要工作流调度系统 一个完整的数据分析系统通常都是由大量任务单元组成:shell 脚本程序,java 程序,mapreduce 程序.hive 脚本等 各任务单元之间存在时间先后及前后依赖关 ...

  4. 巧用Linux 架设TFTP Server备份路由器的配置文件

    本文首发<网管员世界>  转载本文站点: ChinaITLAB TFTP (普通文件传输协议或一般文件传输协议) 大家一定记得在2003年8月12日全球爆发冲击波(Worm.Blaster ...

  5. python3之开发环境PyCharm配置

    1. 安装PyCharm(安装时注意选择python),地址: https://www.jetbrains.com/pycharm/ 2. 安装python 地址: https://www.pytho ...

  6. 紫书 例题 9-9 UVa 10003 (区间dp+递推顺序)

    区间dp,可以以一个区间为状态,f[i][j]是第i个切点到第j个切点的木棍的最小费用 那么对于当前这一个区间,枚举切点k, 可以得出f[i][j] = min{dp(i, k) + dp(k, j) ...

  7. 【转】python的zipfile压缩、解压缩

    网上搜索了很多关于python的zipfile压缩.解压缩.觉得讲述比较详细,例子也很明了.由于比较懒,就直接复制了. 以下内容大部分转于 http://blog.csdn.net/jgood/art ...

  8. Windows Server 2016 辅助域控制器搭建

    Windows Server 2016 主域控制器搭建完成后,继续进行辅助域控制器搭建.1.更改服务器的IP地址2.修改服务器的名称3.打开服务器管理器,选择添加角色和功能4.选择,下一步5.选择,下 ...

  9. Windows 操作系统与 .NET Framework

    Windos 2000 在单位的机房里好不easy才找到一台安装 Windows 2000 Server SP4 操作系统的server.这台硕果仅存的server到本月底也要退役了. Windows ...

  10. DataTable填充实体类返回泛型集合

    昨天找坤哥看到我的一段代码.例如以下: 略微解释下,这段代码时D层查询结束后,将datatable查询到的结果赋值给实体对象的属性,然后返回实体的过程.坤哥看了之后问我.假设实体有500多个属性.难道 ...