思路:

水题。

实现:

 #include <iostream>
#include <cstdio>
#include <set>
using namespace std; int a[][];
int dx[] = { , , , - };
int dy[] = { , , -, };
bool vis[];
int now[];
void dfs(int x, int y, int d)
{
if (d == )
{
int tmp = ;
for (int i = ; i < ; i++)
{
tmp += now[i];
if (i != )
tmp *= ;
}
vis[tmp] = true;
return;
}
for (int i = ; i < ; i++)
{
int nx = x + dx[i];
int ny = y + dy[i];
if (nx >= && nx < && ny >= && ny < )
{
now[d] = a[nx][ny];
dfs(nx, ny, d + );
}
}
}
int main()
{
for (int i = ; i < ; i++)
{
for (int j = ; j < ; j++)
{
cin >> a[i][j];
}
}
for (int i = ; i < ; i++)
{
for (int j = ; j < ; j++)
{
dfs(i, j, );
}
}
int cnt = ;
for (int i = ; i <= ; i++)
{
if (vis[i])
cnt++;
}
cout << cnt << endl;
return ;
}

poj3050 Hopscotch的更多相关文章

  1. POJ3050 Hopscotch 【DFS】

    Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2113   Accepted: 1514 Descrip ...

  2. POJ3050 -- Hopscotch 简单的dfs搜索

    原题链接:http://poj.org/problem?id=3050 (一些文字过会儿再说现在有事儿) #include <cstdio> #include <set> us ...

  3. 《挑战程序设计竞赛》2.1 穷竭搜索 POJ2718 POJ3187 POJ3050 AOJ0525

    POJ2718 Smallest Difference Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6509   Acce ...

  4. 【POJ - 3050】Hopscotch (dfs+回溯)

    -->Hopscotch 这接写中文了 Descriptions: 奶牛们以一种独特的方式玩孩子们的跳房子游戏. 奶牛们创造了一个5x5的格子 他们熟练地跳上其中的一个格子,可以前后左右地跳(不 ...

  5. POJ 3258 River Hopscotch

    River Hopscotch Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 11031   Accepted: 4737 ...

  6. River Hopscotch(二分POJ3258)

    River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 9263 Accepted: 3994 Descr ...

  7. POJ 3258 River Hopscotch (binarysearch)

    River Hopscotch Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 5193 Accepted: 2260 Descr ...

  8. POJ3285 River Hopscotch(最大化最小值之二分查找)

    POJ3285 River Hopscotch 此题是大白P142页(即POJ2456)的一个变形题,典型的最大化最小值问题. C(x)表示要求的最小距离为X时,此时需要删除的石子.二分枚举X,直到找 ...

  9. River Hopscotch(二分)

    Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 5473   Accepted: 2379 Description Every ...

随机推荐

  1. Kemans算法及其Python 实现

    算法优缺点: 优点:容易实现缺点:可能收敛到局部最小值,在大规模数据集上收敛较慢使用数据类型:数值型数据 算法思想 k-means算法实际上就是通过计算不同样本间的距离来判断他们的相近关系的,相近的就 ...

  2. (原创)EasyUI中datagrid的行编辑模式中,找到特定的Editor,并为其添加事件

    有时候在行编辑的时候,一个编辑框的值要根据其它编辑框的值进行变化,那么可以通过在开启编辑时,找到特定的Editor,为其添加事件 // 绑定事件, index为当前编辑行 var editors = ...

  3. Genymotion设置网络桥接

    1,打开Genymotion,找到对应的模拟器,点击“设置”按钮 2,在网络选项中选择桥接 Bridge

  4. mongodb07---用户权限

    用户管理: 注意: 添加用户后,我们再次退出并登陆,发现依然可以直接读数据库? 原因: mongodb服务器启动时, 默认不是需要认证的. 要让用户生效, 需要启动服务器时,就指定 --auth 选项 ...

  5. POJ3159 Candies —— 差分约束 spfa

    题目链接:http://poj.org/problem?id=3159 Candies Time Limit: 1500MS   Memory Limit: 131072K Total Submiss ...

  6. inserting a large number of records with SQLiteStatement.

    Below is a demo application I wrote that creates 100 records programmatically, inserts them using on ...

  7. C语言-1.结构体,2.枚举,3.typedef,4.预处理指令的概念,5.条件编译

    1. 结构体数组 定义:由若干个相同类型的结构体变量组成的有序的集合. 定义格式: 1) 定义结构体的同时定义结构体数组 struct Car{ int lunzi; int speed; }cars ...

  8. ChartCtrl源码剖析之——CChartTitle类

    CChartTitle类顾名思义,该类用来绘制波形控件的标题,它处于该控件的区域,如下图所示: CChartTitle类的头文件. #if !defined(AFX_CHARTTITLE_H__499 ...

  9. asp.net mvc5 使用百度ueditor 本编辑器完整示例(上)

    最近做一个项目,用到了百度ueditor富文本编辑器,功能强大,在线编辑文档,上传图片\视频.附件. MVC 模型的控制器准备: 1.建立模型. 在项目中Model 文件夹中建立 文章 模型,注意如果 ...

  10. Quartz.NET 快速入门

    官网:http://www.quartz-scheduler.net/ API:http://www.quartz-scheduler.net/documentation/index.html 快速入 ...