跳格子

  题目大意:牛像我们一样跳格子,一个5*5的方格,方格有数字,给牛跳5次,可以组成一个6个数字组合字符串,请问能组合多少个字符串?

  题目规模很小,暴力枚举,然后用map这个玩具来检测存不存在就可以了,水题

  

 #include <iostream>
#include <functional>
#include <algorithm>
#include <string>
#include <map> using namespace std; static int matrix[][];//图
static int ans;
string s_tmp = "";
map<string, char>dp; void Search(const int, const int,const int); int main(void)
{
for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
scanf("%d", &matrix[i][j]); for (int i = ; i < ; i++)
for (int j = ; j < ; j++)
Search(i, j, );
cout << ans << endl; return ;
} void Search(const int y, const int x,const int level)
{
if (level == )
{
if (dp.find(s_tmp) == dp.end())
{
dp[s_tmp] = ;
ans++;
}
}
else
{
s_tmp[level] = matrix[y][x] + '';
if (y - >= )
Search(y - , x, level + );
if (y + < )
Search(y + ,x, level + );
if (x - >= )
Search(y, x - , level + );
if (x + < )
Search(y, x + , level + );
}
}

  

  这速度差不多了

Enum:Hopscotch(POJ 3050)的更多相关文章

  1. POJ 3050 Hopscotch【DFS带回溯】

    POJ 3050 题意: 1.5*5的方阵中,随意挑一格,记住这个格子的数字 2.可以上下左右走,走5次,每走一次记录下所走格子的数字 3.经过以上步骤,把所得6个数字连起来,形成一串数字.求共可以形 ...

  2. E - River Hopscotch POJ - 3258(二分)

    E - River Hopscotch POJ - 3258 Every year the cows hold an event featuring a peculiar version of hop ...

  3. POJ -3050 Hopscotch

    http://poj.org/problem?id=3050 给定一个5×5矩阵,问选6个数的不同排列总数是多少! 二维的搜索,注意要判重,数据量很小,直接用map就好. #include<cs ...

  4. POJ 3050 Hopscotch 水~

    http://poj.org/problem?id=3050 题目大意: 在一个5*5的格子中走,每一个格子有个数值,每次能够往上下左右走一格,问走了5次后得到的6个数的序列一共同拥有多少种?(一開始 ...

  5. Hopscotch(POJ 3050 DFS)

    Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2845   Accepted: 1995 Descrip ...

  6. POJ 3050 Hopscotch DFS

    The cows play the child's game of hopscotch in a non-traditional way. Instead of a linear set of num ...

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

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

  8. poj 3050 Hopscotch DFS+暴力搜索+set容器

    Hopscotch Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2774 Accepted: 1940 Description ...

  9. POJ 3050 Hopscotch 四方向搜索

    Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 6761   Accepted: 4354 Descrip ...

随机推荐

  1. BZOJ-3226 校门外的区间 线段数+拆点(类似的思想)

    shabi题....bzoj关键字检查freopen??可怕,,1A的卡了一小时.... 3226: [Sdoi2008]校门外的区间 Time Limit: 10 Sec Memory Limit: ...

  2. BZOJ-1705 Longge的问题 一维GCD SUM 乱搞+质因数分解+...

    2705: [SDOI2012]Longge的问题 Time Limit: 3 Sec Memory Limit: 128 MB Submit: 1871 Solved: 1172 [Submit][ ...

  3. ethtool使用记录

    网卡出现很诡异的问题,把电脑连到一些交换机上是工作的,连到另外一些就不行...交换机上的link灯还时不时的闪一下,看起来像是在尝试连接. 用dmesg查看,看到下面的信息: [ 1112.92211 ...

  4. schemaLocation value = 'xxxxxxxxxxxx' must have even number of URI's

    这是因为没有加上Spring的版本号,加上就行了,如: http://www.springframework.org/schema/beans/spring-beans.xsd -3.2.2 http ...

  5. Chrome浏览器插件

    Chrome 布局 1. 修改Chrome Dock side Chrome 更多工具 -> 开发者工具 -> Customsize and Control Dev Tools

  6. UVA11400照明系统设计&& POJ1260Peals(DP)

    紫书P275: http://acm.hust.edu.cn/vjudge/contest/view.action?cid=105116#problem/A POJ http://poj.org/pr ...

  7. jquery------导入jquery.2.2.3.min.js

    问题: 导入jquery.2.2.3.min.js后MyEclipse会提示代码有错误 方法: 选中jquery.2.2.3.min.js->右键->选择“MyEclipse”中的“Exc ...

  8. 神器Alfred使用

    神器官网:http://www.alfredapp.com/ 许多人装好了之后就再也没有怎么使用过,这软神器, 一直不明白它为什么叫神器,最近研究了一下,真的是,很多东西我们没有好好利用 部分使用功能 ...

  9. FCK编辑器漏洞总结

    1.查看编辑器版本FCKeditor/_whatsnew.html————————————————————————————————————————————————————————————— 2. Ve ...

  10. C/C++内存分配区

    一.起源 C++内存分成5个区,分别是堆.栈.自由存储区.全局/静态存储区和常量存储区. 但这个自由存储区这么一听还是模模糊糊的,和堆好像是一样的,还有同学说起这个问题.   二.个人理解 关于自由存 ...