跳格子

  题目大意:牛像我们一样跳格子,一个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. 【XDU1144】合并模板

    问题 Fate 有 n 个 ACM/ICPC 比赛的模板,每个都是一个独立的 PDF 文件.为了便于打印,万神希望将这些模板合并成一个 PDF 文件.万神有一个工具,可以将至多 k 个 PDF 文件合 ...

  2. CentOS下crontab执行java程序

    阿里云CentOS收不到邮件 在crontab里配置执行脚本,脚本用来执行java程序,死活不执行.单独执行脚本可以运行. 查看crontab的日志文件,/var/log/cron,发现没有收到cro ...

  3. POJ1941 The Sierpinski Fractal

    Description Consider a regular triangular area, divide it into four equal triangles of half height a ...

  4. Linux/Unix System Level Attack、Privilege Escalation(undone)

    目录 . How To Start A System Level Attack . Remote Access Attack . Local Access Attack . After Get Roo ...

  5. C/C++代码中的笔误

    1. 在printf()的参数前加& (2015/10/7) 这是我写的一个数据生成器(generator)片段 +; printf("%d\n", &n);

  6. PL/0编译器(java version) - Interpreter.java

    1: package compiler; 2:   3: import java.io.BufferedReader; 4: import java.io.BufferedWriter; 5: imp ...

  7. WEB开发中的页面跳转方法总结

    PHP header()函数跳转 PHP的header()函数非常强大,其中在页面url跳转方面也调用简单,使用header()直接跳转到指定url页面,这时页面跳转是302重定向: $url = & ...

  8. WebSphere SSLC0008E 无法初始化 SSL 连接。未授权访问被拒绝,或者安全性设置已到期 解决方法

    昨天安装websphere服务器中间件,安装完毕之后,安装验证如下: 猜测是SSL协议版本过低的问题,于是打开IE高级设置: 勾线之后,启动管理控制台: 成功启动web界面如下: 登陆试试:

  9. 每日构建【Daily Build Using CruiseControl.NET and MSBuild】(转载)

    在上一篇项目 管理实践教程二.源代码控制[Source Control Using VisualSVN Server and TortoiseSVN]中 我们已经讲解了如何使用TortoiseSVN和 ...

  10. Ioc注解

    注解: 添加注解时,需要添加context的相关 <?xml version="1.0" encoding="UTF-8"?> <beans ...