思路:

水题。

实现:

 #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. SDUT 3503 有两个正整数,求N!的K进制的位数

    有两个正整数,求N!的K进制的位数 题目链接:action=showproblem&problemid=3503">http://sdutacm.org/sdutoj/prob ...

  2. sqlserver中All、Any和Some用法与区别

    转自:http://blog.csdn.net/gyc1105/article/details/8063624 SQLServer中有三个关键字可以修改比较运算符:All.Any和Some,其中Som ...

  3. 使用Blender批量导出/转换模型

    2.4版本号的Blender API和2.5以上版本号的API有非常大的不同,这里仅仅是提供了思路和2.4版本号的导出方案. 先提供一个脚本,这个是由Blender调用的.用于转换Ogre的Mesh文 ...

  4. EditText设置光标位置问题

    普通设置 EditText 光标显示位置的方法就是 et.setSelection(text.length()); et.setSelection(0); 设置0 就是第一位了. 设置text长度就最 ...

  5. VUE组件如何与iframe通信问题

    vue组件内嵌一个iframe,现在想要在iframe内获取父vue组件内信息,由于本人技术有限,采用的是H5新特性PostMessage来解决跨域问题. postMessage内涵两个API: on ...

  6. 2016/2/25 1, margin auto 垂直方向测试 无效 2,margin重叠 3,哪些是块状哪些是内联 4,display:block inline 导航栏把内联转块状最常见+ 扩展

    1.利用margin auto完成首页居中,并自行研究,竖直方向用margin auto,是什么效果#container{width:1002px;margin: 0px auto;}    竖直方向 ...

  7. 一个DIV相对于另一个DIV定位

    <div style="position:relative"><div style="position:absolute; top:0px; left: ...

  8. java8--异常处理(java疯狂讲义3复习笔记)

    try,catch,finally,throw,throws java将异常分为两种,Checked异常和Runtime异常. IndexOutOfBoundsException NumberForm ...

  9. [NOI2018] 归程 可持久化并查集

    题目描述 本题的故事发生在魔力之都,在这里我们将为你介绍一些必要的设定. 魔力之都可以抽象成一个n 个节点.m 条边的无向连通图(节点的编号从 1至 n).我们依次用 l,a描述一条边的长度.海拔. ...

  10. JDBC连接数据库核心代码

    1.Oracle数据库   Class.forName("oracle.jdbc.driver.OracleDriver").newInstance();   String url ...