`
Simone_chou
  • 浏览: 196301 次
  • 性别: Icon_minigender_2
  • 来自: 广州
社区版块
存档分类
最新评论

Hopscotch(枚举)

    博客分类:
  • POJ
 
阅读更多
Hopscotch
Time Limit: 1000MS   Memory Limit: 65536K
Total Submissions: 1919   Accepted: 1375

Description

The cows play the child's game of hopscotch in a non-traditional way. Instead of a linear set of numbered boxes into which to hop, the cows create a 5x5 rectilinear grid of digits parallel to the x and y axes. 

They then adroitly hop onto any digit in the grid and hop forward, backward, right, or left (never diagonally) to another digit in the grid. They hop again (same rules) to a digit (potentially a digit already visited). 

With a total of five intra-grid hops, their hops create a six-digit integer (which might have leading zeroes like 000201). 

Determine the count of the number of distinct integers that can be created in this manner.

Input

* Lines 1..5: The grid, five integers per line

Output

* Line 1: The number of distinct integers that can be constructed

Sample Input

1 1 1 1 1
1 1 1 1 1
1 1 1 1 1
1 1 1 2 1
1 1 1 1 1

Sample Output

15

Hint

OUTPUT DETAILS: 
111111, 111112, 111121, 111211, 111212, 112111, 112121, 121111, 121112, 121211, 121212, 211111, 211121, 212111, and 212121 can be constructed. No other values are possible.

      题意:

      给出一个 5 X 5 的地图,从任意一个点出发,找出走 6 步可能的序列。输出总数。

 

      思路:

      DFS,每个点都暴搜一次,同时保存序列,判重即可。判重可以转成整数来判重就会更加简洁方便了。

   

      AC:

#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cstdlib>

int num[500000][10], fin[10];
int Map[10][10];
int dir[4][2] = {-1, 0, 0, -1, 1, 0, 0, 1};
int sum;

void dfs(int x, int y, int ans) {
        fin[ans] = Map[x][y];

        if (ans == 6) {
                for (int i = 1; i <= sum; ++i) {
                        int j;
                        for (j = 1; j <= 6; ++j) {
                                if (fin[j] != num[i][j]) break;
                        }
                        if (j == 7) return;
                }

                ++sum;
                for (int i = 1; i <= 6; ++i) {
                        num[sum][i] = fin[i];
                }

                return;
        }

        for (int i = 0; i < 4; ++i) {
                int nx = x + dir[i][0];
                int ny = y + dir[i][1];

                if (nx >= 1 && ny >= 1 &&
                    nx <= 5 && ny <= 5)
                    dfs(nx, ny, ans + 1);
        }
}

int main() {
        sum = 0;

        for (int i = 1; i <= 5; ++i) {
                for (int j = 1; j <= 5; ++j) {
                        scanf("%d", &Map[i][j]);
                }
        }

        for (int i = 1; i <= 5; ++i) {
                for (int j = 1; j <= 5; ++j) {
                        dfs(i, j, 1);
                }
        }

        printf("%d\n", sum);

        return 0;
}

 

 

分享到:
评论

相关推荐

    jQuery跳房子插件hopscotch

    插件描述 跳房子是一个框架,使开发人员可以轻松预览产品并添加到他们的网页 跳房子接受JSON对象作为输入,并提供开发人员来控制渲染巡演显示和管理的游览进度的API。 参考博文地址:...

    前端项目-hopscotch.zip

    **前端项目-hopscotch** 是一个专为开发者设计的框架,其主要目的是简化在网页应用中集成产品导览的功能。这个框架使得开发人员无需从零开始编写复杂的代码,就能快速地在自己的页面上添加交互式的用户指导,帮助新...

    POJ3258-River Hopscotch

    【标题】"POJ3258-River Hopscotch"是一个编程竞赛题目,源自北京大学的在线判题系统POJ(Problem Online Judge)。这个题目挑战参赛者的算法设计和实现能力,通常涉及计算机科学中的数据结构和算法知识。 【描述】...

    Hopscotch-map:使用Hopscotch散列的快速哈希图和哈希集的C ++实现

    Hopscotch Map是一种高效的数据结构,它是一种哈希表实现,特别优化了冲突处理机制,以提供更快的查找、插入和删除操作。这个C++实现是头文件库(header-only library),意味着用户只需要包含对应的头文件就可以...

    poj 3050 Hopscotch.md

    poj 3050 Hopscotch.md

    Hopscotch, Hopscotch学习平台启发儿童的色彩方案.zip

    Hopscotch, Hopscotch学习平台启发儿童的色彩方案 跳房子主题 基于跳房子的色彩方案kids儿童学习平台 支持的应用程序:AceAtomBBEditcodemirror/括号Gedithighlight.js构思iTerm2MacDownMouNo

    hopscotch

    标题“Hopscotch”可能指的是一个项目或软件的名称,而描述“跳房子”则可能是该项目或软件的核心概念或特点的隐喻。由于标签指明了“C#”,我们可以推测这是一个使用C#编程语言开发的项目。跳房子游戏通常与儿童...

    Hopscotch:包装来自 LinkedIn 的 Hopscotch 库的 Mendix 小部件

    ** Hopscotch: LinkedIn 的 Hopscotch 库与 Mendix 小部件的集成详解 ** 在 IT 领域,特别是在应用程序开发中,用户引导和交互性是提升用户体验的关键因素。LinkedIn 的 Hopscotch 库就是一个专为此目的设计的 ...

    Hopscotch-Recorder:一种轻松有效的方式来记录您的游览步骤

    /css根据您的主题包含CSS文件和differentnet hopscotch css文件。 /img包含图像文件。 /scripts包含javascript文件,包括chrome扩展的内容脚本和背景脚本。 我如何开始使用Hopscotch Recorder? 安装chrome扩展...

    ember-hopscotch:Hopscotch 框架的 Ember 插件

    余烬跳房子 Hopscotch 框架的 Ember 插件 安装 ember install ember-hopscotch 在 Ember 中的使用 Hopscotch 被添加为全局变量hopscotch 要阅读有关 Hopscotch API 及其用法的更多信息: :

    GLPI_HOPSCOTCH-开源

    **GLPI_HOPSCOTCH 开源项目详解** GLPI(Gestionnaire Libre de Parc Informatique,自由计算机资产管理)是一款开源的信息技术资源管理软件,广泛用于企业、机构和组织内部的IT资产管理和服务台功能。而GLPI_...

    Python库 | py_hopscotch_dict-1.0.0-py2.py3-none-any.whl

    资源分类:Python库 所属语言:Python 资源全名:py_hopscotch_dict-1.0.0-py2.py3-none-any.whl 资源来源:官方 安装方法:https://lanzao.blog.csdn.net/article/details/101784059

    hopscotch:用于构建用户可以浏览的无限 2d 路径的 Javascript 库,类似于跳房子游乐场

    -hopscotch.js -hopscotch.min.js -hopscotch.css -hopscotch.min.css -i18n --hopscotch_fr.js --hopscotch_es.js --hopscotch_de.js -demos --demo1.html --demo2.html -docs --api.md --getting-started.md 《跳...

    hopscotchApp

    "hopscotchApp"是一个基于AngularJS开发的应用程序,它以“跳房子”为主题,可能是一种结合了游戏元素和信息搜索功能的创新设计。AngularJS是Google维护的一个强大的前端JavaScript框架,它允许开发者构建交互性强、...

    跳房子:一种框架,使开发人员可以轻松地向其页面添加产品浏览

    Hopscotch接受一个游览JSON对象作为输入,并为开发人员提供一个API,以控制渲染游览显示和管理游览进度。 要了解有关Hopscotch和API的更多信息,请查看 。 这是什么 /archives包含Hopscotch以前和当前发行版的.zip...

    hs-tools:跳房子工具

    在这里,我上传了一些关于Hopscotch项目及其JSON结构的工具。 跳房子帮助指南 我正在研究的有关跳房子中的块的协作项目。 收集的有关块的信息放在此处。 任何人都可以为该项目做出贡献,因为我们非常感谢您的帮助。...

    7款jQuery常用插件

    2. **jQuery跳房子插件hopscotch**:Hopscotch是一个用于创建用户引导体验的插件,帮助新用户了解网站或应用的功能。通过自定义的提示和路径,它可以引导用户逐步了解每个功能,提高用户对网站的熟悉度和满意度。 3...

    GPU无锁跳步哈希表.pdf

    GPU无锁跳步哈希表(GPU lock-free hopscotch Hash table,GLHT)是一种专为GPU设计的高效内存索引结构,旨在解决并发访问和动态更新的问题。 传统的哈希表在CPU上通常采用锁机制来处理并发访问,但这种方法在GPU上...

Global site tag (gtag.js) - Google Analytics