思路:

水题。

实现:

 #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. 2016/05/16 UEditor 文本编辑器 使用教程与使用方法

    第一:百度UEditor编辑器的官方下载地址 ueditor 官方地址:http://ueditor.baidu.com/website/index.html 开发文档地址:http://uedito ...

  2. C++ 函数部分(1)

    1.编写一个求X的n次方的函数 .csharpcode, .csharpcode pre { font-size: small; color: black; font-family: consolas ...

  3. 理解ValueStack的基本机制

    ValueStack基础:OGNL(Object Graphic Navigation Language) OGNL是Struts2中使用的一种表达式语言.它可以用于:   · 在JSP页面,使用标签 ...

  4. 用css解决Unigui在IE系列浏览器中字体变小的问题(设置UniServeModule的customcss属性)

    Unigui运行在chrome浏览器下可以有最佳的效果,但用ie打开用unigui做的项目会发现字体明显小一截,可以用自定义css来解决这个问题. 可以在UniServeModule的customcs ...

  5. RK3288-OTA编译失败解决办法【转】

    本文转载自:http://blog.csdn.net/wangxueming/article/details/52448630 在执行make  otapackage的时候出现该错误,是由于drmsi ...

  6. YTU 2416: C语言习题 成绩输出

    2416: C语言习题 成绩输出 时间限制: 1 Sec  内存限制: 128 MB 提交: 1111  解决: 417 题目描述 输入n(<=10)个学生的姓名.学号和成绩,将其中不及格者的姓 ...

  7. 二.OC基础--1,对象的存储细节,2,#pragma mark指令,3,函数和对象方法的区别,4,对象和方法之间的关系 ,5.课堂习题

    1,对象的存储细节, 1. 当创建一个对象的时候:Person *p1 = [Person new],做了三件事情: 1,申请堆内存空间: 2,给实例变量初始化: 3,返回所申请空间的首地址; 2. ...

  8. URAL2104. Game with a Strip(博弈)

    There is a strip 1 × n with two sides. Each square of the strip (their total amount is 2n, n squares ...

  9. [Codeforces Round #461 (Div2)] 题解

    [比赛链接] http://codeforces.com/contest/922 [题解] Problem A. Cloning Toys          [算法] 当y = 0 ,   不可以 当 ...

  10. 《JAVA与模式》之迭代子模式

    迭代子模式又叫游标(Cursor)模式,是对象的行为模式.迭代子模式可以顺序地访问一个聚集中的元素而不必暴露聚集的内部表象(internal representation). 聚集和JAVA聚集 多个 ...