思路:

水题。

实现:

 #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. ZrcListView

    https://github.com/zarics/ZrcListView

  2. 关于集成支付宝SDK的开发

    下载 首先,你要想找到这个SDK,都得费点功夫.如今的SDK改名叫移动支付集成开发包了,下载页面在 这里 的 "请点此下载集成开发包" Baidu和Googlep排在前面的支付宝开 ...

  3. sql里的in对应linq的写法 及 IQueryable转化为Dictionary

    string[] arID = { "0001", "0002" }; var dict = this.service.GetMyList(m => ar ...

  4. S2SH的集成(Struts2,Spring,Hibernate)----青软S2SH(笔记)

  5. SpringMVC_中文乱码的配置 --跟海涛学SpringMVC(和自己在项目中的实际使用的对比)

    spring Web MVC框架提供了org.springframework.web.filter.CharacterEncodingFilter用于解决POST方式造成的中文乱码 <filte ...

  6. bzoj 4596

    4596: [Shoi2016]黑暗前的幻想乡 Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 257  Solved: 152[Submit][Sta ...

  7. Oracle 11g导出来的dmp导入到 10g的数据库(IMP-00010:不是有效的导出文件,头部验证失败)

    原文地址:http://www.cnblogs.com/alxc/archive/2011/03/25/1995279.html 因为喜欢新的东西,所以基本上电脑的开发工具都是最新的,oracle也装 ...

  8. 腾讯API

    相关文档: API列表  腾讯开放平台联调工具集  公共返回码说明 SDK下载

  9. Java ServerSocket的服务端代码介绍

    转自:http://developer.51cto.com/art/201003/190007.htm 所谓Java ServerSocket通常也称作"套接字",有不少的时候需要 ...

  10. 关于jenkins的安装及自动部署

    1. 安装Jenkins 1.1 准备Linux服务器, 关闭防火墙禁止开机启动 systemctl stop firewalld.service #停止firewall systemctl disa ...