Enum:Hopscotch(POJ 3050)

题目大意:牛像我们一样跳格子,一个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)的更多相关文章
- POJ 3050 Hopscotch【DFS带回溯】
POJ 3050 题意: 1.5*5的方阵中,随意挑一格,记住这个格子的数字 2.可以上下左右走,走5次,每走一次记录下所走格子的数字 3.经过以上步骤,把所得6个数字连起来,形成一串数字.求共可以形 ...
- E - River Hopscotch POJ - 3258(二分)
E - River Hopscotch POJ - 3258 Every year the cows hold an event featuring a peculiar version of hop ...
- POJ -3050 Hopscotch
http://poj.org/problem?id=3050 给定一个5×5矩阵,问选6个数的不同排列总数是多少! 二维的搜索,注意要判重,数据量很小,直接用map就好. #include<cs ...
- POJ 3050 Hopscotch 水~
http://poj.org/problem?id=3050 题目大意: 在一个5*5的格子中走,每一个格子有个数值,每次能够往上下左右走一格,问走了5次后得到的6个数的序列一共同拥有多少种?(一開始 ...
- Hopscotch(POJ 3050 DFS)
Hopscotch Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2845 Accepted: 1995 Descrip ...
- 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 ...
- 【POJ - 3050】Hopscotch (dfs+回溯)
-->Hopscotch 这接写中文了 Descriptions: 奶牛们以一种独特的方式玩孩子们的跳房子游戏. 奶牛们创造了一个5x5的格子 他们熟练地跳上其中的一个格子,可以前后左右地跳(不 ...
- poj 3050 Hopscotch DFS+暴力搜索+set容器
Hopscotch Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2774 Accepted: 1940 Description ...
- POJ 3050 Hopscotch 四方向搜索
Hopscotch Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 6761 Accepted: 4354 Descrip ...
随机推荐
- Cocos2d-X3.0 刨根问底(一)----- 概览
罗嗦几句,本系列文章记录了小鱼(本人)自学Cocos2D-X的整个过程,主要从分析Cocos2D-x的源码方式来学习Cocos2d-x这样一个优秀的游戏引擎架构,本着不但要知其然还要知其所以然的学习态 ...
- 【poj1740】 A New Stone Game
http://poj.org/problem?id=1740 (题目链接) 男人八题之一 题意 对于n堆石子,每堆若干个,两人轮流操作,每次操作分两步,第一步从某堆中去掉至少一个,第二步(可省略)把该 ...
- SSL、TLS协议格式、HTTPS通信过程、RDP SSL通信过程
相关学习资料 http://www.360doc.com/content/10/0602/08/1466362_30787868.shtml http://www.gxu.edu.cn/college ...
- C++用new和不用new创建类对象区别
new创建类对象,使用完后需使用delete删除,跟申请内存类似.所以,new有时候又不太适合,比如在频繁调用场合,使用局部new类对象就不是个好选择,使用全局类对象或一个经过初始化的全局类指针似乎更 ...
- libcurl with telnet
#include <stdio.h>#include <string.h>#include <curl/curl.h>#include <curl/easy. ...
- iOS exit(0); 直接退出程序
exit();
- 如何使用网盘托管git项目
话说近年来git已经成为项目源代码管理的标准工具,有不少免费托管网站可供使用,详情参考这篇文章: http://www.cnblogs.com/zdz8207/archive/2012/05/20/2 ...
- CSS 2D转换 matrix() 详解
2D转换 IE10.Firefox.Opera 支持 transform 属性 Chrome.Safari 需要前缀 -webkit- . IE9 需要前缀 -ms- . translate():接收 ...
- linux 运行级别与chkconfig
一.Linux的运行级别 在装MySQL的时候,才知道了Linux的运行级别这么一回事.汗…自己太水了…下面总结一下: 什么是运行级别呢?简单点来说,运行级别就是操作系统当前正在运行的功能级别.级别是 ...
- 只能输入汉字js脚本
<html> <head> <meta http-equiv="Content-Type" content="text/html" ...