POJ 3050 Hopscotch(dfs暴力)

强化学习经典算法笔记(九):LSTM加持的PolicyGradient算法 强化学习经典算法笔记(九):LSTM加持的PolicyGradient算法 在上文《强化学习经典算法笔记(八):LSTM加持的A2C算法解决POMDP问题》的基础上,实现了LSTM+MLP的Policy Gradient算法。 实现过程如下: import argparse, math, os, sys import numpy as np import gym from gym import wrappers import matplotlib.pyplot as plt import torch fr 阅读详情

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*5的矩阵,每次走六步,组成一个六位数,看看能组成多少个不同的六位数。

解题方法:

在main函数中暴力让每一个点都当作顶点,然后用深搜遍历搜够步然后在判断看这个数是否出现过,如果没有存入数组。最后输出那个数组的下标。

AC代码:

#include<stdio.h>
#include<string.h>

int next[4][2]={1,0, -1,0, 0,1, 0,-1};
int s[100000],e[10][10],ans;
void dfs(int x,int y,int p,int sum)
{
	int tx,ty,k,i,flag;
	if(p==6)
	{
		if(ans==1)
			s[ans++]=sum;
		else
		{
			flag=0;
			for(i=1;i<ans;i++)
			{
				if(s[i]==sum)
				{
					flag=1;
					break;
				}
			}
			if(flag==0)
				s[ans++]=sum;
		}
		return ;
	}
	
	for(k=0;k<4;k++)
	{
		tx=x+next[k][0];
		ty=y+next[k][1];
		if(tx<1||ty<1||tx>5||ty>5)
			continue;
		dfs(tx,ty,p+1,10*sum+e[tx][ty]);
	}
 } 
 
int main(void)
{
	int i,j;
	for(i=1;i<=5;i++)
		for(j=1;j<=5;j++)
			scanf("%d",&e[i][j]);
	ans=1;
	for(i=1;i<=5;i++)
		for(j=1;j<=5;j++)
			dfs(i,j,1,e[i][j]);
	printf("%d\n",ans-1);
	return 0;
}
320x240 TFT屏的SPI DMA驱动避坑指南:基于HC32F460的时序调试心得 本文详细介绍了基于HC32F460 MCU驱动320x240 TFT屏的SPI DMA实战经验,涵盖硬件设计、波形诊断、DMA优化及高级调试技巧。重点解析SPI时序配置、DMA缓冲区对齐等常见问题,并提供逻辑分析仪波形诊断方法和性能优化策略,帮助开发者规避典型陷阱,提升显示性能。 阅读详情

相关推荐

YOLOv5s模型训练全流程解析:从数据准备到实战检测

本文详细解析了YOLOv5s模型训练的全流程,涵盖从环境搭建、数据准备与格式转换,到模型训练、参数调优及实战检测的完整步骤。文章提供了具体的代码示例和常见问题解决方案,旨在帮助开发者,特别是新手,高效掌握YOLOv5s模型训练的核心技术,并成功应用于实际检测任务中。

weixin_29041767的博客 334

【题解】POJ 3050 Hopscotch(搜索)

POJ 3050 Hopscotch 原题 https://vjudge.net/problem/POJ-3050 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...

bu_shushu的博客 578

Flink SQL数据血缘实战:如何用Calcite追踪字段级数据流向(附源码示例)

本文深入探讨了如何利用Apache Calcite解析Flink SQL执行计划,实现字段级数据血缘的追踪。通过扩展Calcite的元数据处理器,特别是针对Flink特有的Snapshot等节点,文章提供了从获取优化后的逻辑计划到提取并可视化血缘关系的完整实战方案,并附有核心源码示例,帮助开发者构建实时数仓的数据治理能力。

weixin_29032337的博客 142

【题解】Hopscotch POJ - 3050 ⭐⭐ 【Dfs】

Hopscotch POJ - 3050 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...

Suprit's blog 855

GNSS/INS松组合导航实战:如何用卡尔曼滤波提升定位精度(附MATLAB代码)

本文深入探讨了GNSS/INS松组合导航的工程实践,详细阐述了如何利用卡尔曼滤波算法融合卫星与惯性数据以提升定位精度。内容涵盖从仿真环境搭建、误差状态卡尔曼滤波器(ESKF)设计,到状态与观测方程实现、噪声参数调试及常见问题排查的全过程,并提供了可直接运行的MATLAB代码,为开发高精度、鲁棒的组合导航系统提供实战指南。

weixin_29057163的博客 165

华为云HCS解决方案笔记HUAWEI CLOUD Stack【面试篇】

华为云解决方案介绍、华为云服务介绍,华为云网络平面规划等

weixin_48375618的博客 1万+

Hopscotch POJ - 3050

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 an...

songziyuan_的博客 216

【SLAM】探索explore_lite在移动机器人自主建图中的高效边界检测策略

本文深入解析了explore_lite在移动机器人自主建图中的应用,重点探讨了其高效的贪婪边界检测策略。该工具包专为资源受限平台设计,通过直接利用SLAM生成的地图信息,以极低的计算开销实现快速、稳定的未知区域探索,并与move_base导航框架无缝协作,是轻量级机器人自主探索的优选方案。

purple的博客 1067

Hopscotch

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 paral

Accepted ALL lve 639

PMSM控制系列文章进阶-8.电流、角度采样及其同步

摘要:本文分析了高低压电机在电流和角度采样中的不同方案选择。高压电机采用霍尔传感器和旋变进行隔离采样,低压电机则使用shunt电阻和磁编码器以降低成本。重点讨论了采样时间补偿问题:电流采样需与PWM周期同步,角度采样需考虑传感器延迟;通过park变换和反park变换时需补偿采样与发波的时间差,提出了通过测试母线电流或Ud变化来验证补偿时间准确性的方法。文中还介绍了对传感器信号进行软解码处理的方法,包括消除直流偏置、增益误差和正交误差等参数的自学习过程。

weixin_41343701的博客 613

物联网系列③——基于ESP8266与点灯科技平台的温湿度计设计(接入小爱同学)

物联网系列③——基于ESP8266与点灯科技平台的温湿度计设计(接入小爱同学)一、设计目标二、电路展示三、存在的问题四、代码五、需要注意的问题 一、设计目标       前一阵子偶然接触到点灯科技平台,产生了制作一块ESP8266电路板,拥有以下功能: 使用CH340对ESP8266进行程序下载 使用DHT11进行温湿度数据读取 使用点灯科技平台接入物联网,可通过手机APP获得室内温湿度 接入小爱同学,通过语音获取室内温湿度信息 Mico US

weixin_43278295的博客 8853

POJ--3050--BFS

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 an...

queque_heiya的博客 484

实时系统vxWorks - 虚拟机环境搭建

概述VxWorks 操作系统是美国WindRiver公司于1983年设计开发的一种嵌入式实时操作系统(RTOS),是嵌入式开发环境的关键组成部分。良好的持续发展能力、高性能的内核以及友好的...

不只会拍照的程序猿 7853

poj 3050 Hopscotch 【DFS 暴力】

 Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2455   Accepted: 1751 Description The cows play the child's game of hopscotch in a non-tradit

世界很大 556

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

POJ3050 Hopscotch【DFS+暴力】

  Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 5258   Accepted: 3460 Description The cows play the child's game of hopscotch in a non-traditional way. Inst...

海岛Blog 723

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

poj 3050 Hopscotch(暴力dfs)

问题描述 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

坏坏的薯片 285

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

POJ 3050 Hopscotch 暴力 DFS

DFS枚举每个点开始的全部长度为6的数字串,插入到set里面。 //#pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cstdlib> #include<algorithm> #in...

weixin_34247032的博客 119

(POJ3050) Hopscotch (暴力DFS)

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 an...

alex1997222的博客 265

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

Hopscotch Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 2774 Accepted: 1940 Description The cows play the child's game of hopscotch in a non-traditional

smilesundream的博客 536

poj3050 Hopscotch(暴力dfs)

题意 跳格子,从任意一个点开始跳,  跳六步会生成一个字符串序列, 求5*5格子上, 能生成出多少个不同的字符串序列。 题解 暴力dfs。 不用标记vis数组剪枝,顺序可能不同, 不用开flag数组使同次访问不同格,一个序列里某个格允许访问多次。 偶槽数据结构课上敲题用C++编译器还爆map的错真是心态爆炸 代码 #pragma warning(disable:47...

小衣同学的博客 357

poj 3050 Hopscotch(dfs暴力)

Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3951   Accepted: 2627 Description The cows play the child's game of hopscotch in a non-traditional

L-75的专栏 460

POJ 3050 Hopscotch(dfs,暴力搜索)

 Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2780   Accepted: 1944 Description The cows play the child's game of hopscotch in a non-traditiona

Chunzhen的博客 921

poj 3050 Hopscotch(暴力+dfs)

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 paralle...

weixin_30672019的博客 134

POJ 3050 Hopscotch

POJ 3050题目大意如下: 这也是一道暴力搜索,直接DFS,代码如下 #include #include #include #include using namespace std; int dirX[] = {0, 1, 0, -1}; int dirY[] = {1, 0, -1, 0}; int Grap[6][6]; int sum; map data; void df

kornberg_fresnel的博客 461

POJ 3050 Hopscotch (dfs)

Hopscotch Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 2244   Accepted: 1608 Description The cows play the child's game of hopscotch in a non-traditiona

TaoSama's Microcosm 531
上一篇: POJ 1083 Moving Tables
下一篇: POJ 2524 Ubiquitous Religions(并查集)
鳳九~
博客等级 码龄8年 1384粉丝 215原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值