思路:

水题。

实现:

 #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. Eclipse项目遇到问题汇总

    1:gc overhead limit exceeded     原因:这是由于项目中eclipse内存分配不足导致     修改:修改eclipse.ini文件     修改如下:          ...

  2. 2016/05/15 ThinkPHP3.2.2 表单自动验证实例 验证规则的数组 直接写在相应的控制器里

    使用TP 3.2框架 验证规则也可以写到模型里,但感觉有些麻烦, 一是有时候不同页面验证的方式会不一样, 二是看到这个   Add  事件里的代码,就清楚要接收什么数据,如何验证数据能够在第一眼有个大 ...

  3. java8--网络编程(java疯狂讲义3复习笔记)

    重点复习一下网络通信和代理 java的网络通信很简单,服务器端通过ServerSocket建立监听,客户端通过Socket连接到指定服务器后,通信双方就可以通过IO流进行通信. 需要重点看的工具类:I ...

  4. Lucene Core Solr

    Apache Lucene - Welcome to Apache Lucene https://lucene.apache.org/ The Apache LuceneTM project deve ...

  5. list if else 遍历 特征合并

    特征合并 import re l = ['a', 'b1'] ll = [i if re.search('\d', i) is None else i[0:re.search('\d', i).end ...

  6. Using Python with TurboGears A complete web framework integrating several Python projects

    Using Python with TurboGears TurboGears is a Python web framework based on the ObjectDispatch paradi ...

  7. StyleBook皮肤控件的使用

    StyleBook 介绍及VICEN对皮肤控件的一些看法可以说StyleBook的出现,简直是皮肤控件厂商的噩梦,因为用户可以通过StyleBook快速切换控件样式,而不需要在去购买第三方换肤控件,对 ...

  8. POJ - 3041 Asteroids(最小点覆盖数)

    1.有一个n*n的矩阵,在矩阵上有k个行星,用武器射击一次可以消灭一行或者一列的行星,求消灭所有的行星的最少射击次数. 2.最小点覆盖数 = 最大匹配数 主要在于转化:看图: 这样,在建成的二分图中, ...

  9. mac下安装eclipse+CDT

    测试文件test.cpp #include <iostream>using namespace std; int main() {    cout << "!!!He ...

  10. SPOJ:Just One Swap(统计&思维)

    You are given an array of size N. How many distinct arrays can you generate by swapping two numbers ...