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

【题意】

在这里输入题意

【题解】

借鉴网上的题解的。
思路是。
用"标准化"的思想。
确定基准点(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;
}

最新文章

  1. javascript高性能编程-算法和流程控制
  2. Delphi iOS 开启文件共享 UIFileSharingEnabled
  3. 纯JSP实现简单登录跳转
  4. &amp;,引用复制@,忽略错误提示
  5. java动态生成带下拉框的Excel导入模板
  6. SSAS计算列如果是中文名称时,必须要在名字外加中括号
  7. init_MUTEX
  8. 当分页语句遇到union all
  9. 通过编程为Outlook 2007添加邮件规则
  10. 使用Material Design 应用主题
  11. monkey常用命令实例
  12. docker保存日志文件到本地
  13. 使用Gadget 做usb鼠标键盘设备
  14. Python单元测试框架unittest
  15. Python 属性与方法 概念理解
  16. MySQL 5.7的原生JSON数据类型使用
  17. position属性的总结
  18. 3-18 关于namespace,双冒号::的用法; SelfYield.
  19. java bulid path 和 WEB-INF/lib 下jar 包区别
  20. 实验三 Java猜数字游戏开发

热门文章

  1. BZOJ 1082 暴搜
  2. Codeforces Round #206 (Div. 2) 部分题解
  3. ES6学习笔记(四)数值的扩展
  4. 学习TF:《TensorFlow机器学习实战指南》中文PDF+英文PDF+代码
  5. 2017-2018年红头发新版Cisco认证网络工程师(CCNA-R&amp;S)全新讲解分享
  6. 【VC++学习笔记四】MFC应用程序中框架类的获取
  7. SpringBoot 整合 Mybatis 和 Mysql (详细版)
  8. WPF通用框架ZFS《项目结构介绍01》_模块介绍
  9. Android.mk脚本推断文件是否存在
  10. tsp问题——遗传算法解决