POJ 3050 Hopscotch 裸广搜
来源:互联网 发布:12345打字软件下载 编辑:程序博客网 时间:2024/06/05 23:41
题目链接: POJ 3050
题目大意:5*5的方格从里面能取出多少个不同的连续的6位数字组合。
一开始居然打算用hash。。。发现要hash[10^7],最后用的set,还是stl大法好。
/***********************************Problem: 3050 User: ChenyangDuMemory: 1024K Time: 94MSLanguage: G++ Result: Accepted************************************/#include<iostream>#include<cstdio>#include<cstring>#include<set>using namespace std;const int map[2][4] = {1,0,0,-1,0,1,-1,0};int in[5][5],mod[6];set <int> se;void input(){ for(int i=0;i<5;i++){ for(int j=0;j<5;j++) scanf("%d",&in[i][j]); }}void outcome(){ int r = 0; for(int i=0;i<6;i++){ r *= 10; r += mod[i]; } se.insert(r); return;}void dfs(int x,int y,int s){ if(s == 6){ outcome(); return ; } mod[s] = in[x][y]; for(int i=0;i<4;i++){ int a = map[0][i] + x; int b = map[1][i] + y; if(a>=0 && a<5 && b>=0 && b<5){ dfs(a,b,s+1); } }}int main(){ //freopen("in.txt","r",stdin); input(); for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ dfs(i,j,0); } } cout<<se.size(); return 0;}
阅读全文
0 0
- POJ 3050 Hopscotch 裸广搜
- POJ 3050 Hopscotch
- poj 3050 Hopscotch DFS
- poj 3050 Hopscotch
- POJ-3050-Hopscotch
- poj 3050 Hopscotch
- POJ 3050 Hopscotch 水~
- POJ 3050 Hopscotch
- POJ-3050 Hopscotch
- POJ 3050 Hopscotch DFS
- POJ 3050 Hopscotch
- POJ 3050 Hopscotch
- poj 3050 Hopscotch 【DFS】
- poj 3050 Hopscotch
- Hopscotch (poj 3050 dfs)
- POJ 3050 Hopscotch
- Hopscotch.(POJ-3050)
- Hopscotch - POJ 3050 DFS
- BZOJ 2429 最小生成树 解题报告
- Python之创建虚拟环境
- mongoDB与mysql的区别
- 串口的设置
- C++ 多重继承之内存存储
- POJ 3050 Hopscotch 裸广搜
- py-faster-rcnn算法caffe配置,训练及应用到自己的数据集
- 代码注释和编码规范
- Idea GitLab设置远程Remote仓库时显示authentication failed for xxx错误
- 数据结构实践之前篇
- RxJava系列教程之过滤篇(四)
- 【报错】常见JavaWeb/SSM错误
- 何时使用或何时不使用malloc函数
- 实验报告6_MPEG音频编码