HDU - 5706 GirlCat (dfs)

基于51单片机的汽车大灯控制系统:从硬件设计到软件实现的完整项目解析 单片机作为嵌入式系统的核心,通过其I/O端口、定时器和中断等资源,实现对物理世界的感知与控制。其工作原理在于执行预先编写的程序逻辑,处理输入信号并驱动输出设备,从而完成特定的自动化任务。在工业控制、智能家居和汽车电子等领域,单片机因其成本低、可靠性高而具有重要技术价值。例如,在汽车电子中,它常用于实现车身控制模块(BCM)等基础功能。本文聚焦于一个具体的应用场景——汽车大灯控制,详细阐述了如何利用经典的STC89C52单片机,结合继电器或MOSFET驱动电路、光敏传感器以及状态机编程,构建一个具备远近光切换 阅读详情

GirlCat

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1020    Accepted Submission(s): 642


Problem Description
As a cute girl, Kotori likes playing ``Hide and Seek'' with cats particularly.
Under the influence of Kotori, many girls and cats are playing ``Hide and Seek'' together.
Koroti shots a photo. The size of this photo is  n\times m, each pixel of the photo is a character of the lowercase(from `a' to `z').
Kotori wants to know how many girls and how many cats are there in the photo.

We define a girl as -- we choose a point as the start, passing by 4 different connected points continuously, and the four characters are exactly ``girl'' in the order.
We define two girls are different if there is at least a point of the two girls are different.
We define a cat as -- we choose a point as the start, passing by 3 different connected points continuously, and the three characters are exactly ``cat'' in the order.
We define two cats are different if there is at least a point of the two cats are different.

Two points are regarded to be connected if and only if they share a common edge.
 

Input
The first line is an integer  T which represents the case number.

As for each case, the first line are two integers  n and  m, which are the height and the width of the photo.
Then there are  n lines followed, and there are  m characters of each line, which are the the details of the photo.

It is guaranteed that:
T is about 50.
1\leq n\leq 1000.
1\leq m\leq 1000.
\sum (n\times m)\leq 2\times 10^6 .
 

Output
As for each case, you need to output a single line.
There should be 2 integers in the line with a blank between them representing the number of girls and cats respectively.

Please make sure that there is no extra blank.

 

Sample Input
  
3 1 4 girl 2 3 oto cat 3 4 girl hrlt hlca
 

Sample Output
  
1 0 0 2 4 1
 

Source
 

Recommend
liuyiding

题意:给一个 n * m 的矩阵,问其中有多少个 "girl" 和 "cat"

#include <bits/stdc++.h>
using namespace std;

int t, n, m;
char a[1003][1003];
int ans1, ans2;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};

int dfs(int i, int j, int k, int f){
    for(int t = 0; t < 4; t++){
        int ii = i + dx[t];
        int jj = j + dy[t];
        if(ii >= 0 &&ii < n && jj >= 0 && jj < m){
            if(f){
                if(k == 1 && a[ii][jj] == 'i'){
                    dfs(ii, jj, 2, f);
                }
                if(k == 2 && a[ii][jj] == 'r'){
                    dfs(ii, jj, 3, f);
                }
                if(k == 3&& a[ii][jj] == 'l'){
                    ans1++;
                }
            }
            else {
                if(k == 1 && a[ii][jj] == 'a'){
                    dfs(ii, jj, 2, f);
                }
                if(k == 2 && a[ii][jj] == 't'){
                    ans2++;
                }
            }
        }
    }
}

int main(){
    scanf("%d", &t);
    while(t--){
        scanf("%d%d", &n, &m);
        for(int i = 0; i < n; i++){
            scanf("%s", a[i]);
        }
        ans1 = 0, ans2 = 0;
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                if(a[i][j] == 'g'){
                    dfs(i, j, 1, 1);
                }
                if(a[i][j] == 'c'){
                    dfs(i, j, 1, 0);
                }
            }
        }
        printf("%d %d\n", ans1, ans2);
    }
}


告别调试烦恼:用Lattice Diamond手把手教你JTAG烧录FPGA(附SRAM/Flash模式详解) 本文详细介绍了使用Lattice Diamond软件进行JTAG烧录FPGA的全流程,包括SRAM临时调试和Flash固化的核心区别。从环境准备、硬件连接到文件准备、烧录模式选择,再到典型问题排查和高级技巧,手把手教你快速掌握FPGA烧录技术,提升开发效率。 阅读详情

相关推荐

python使用TensorRT报错,多线程或多进程中使用问题

python使用TensorRT报错,Cuda Runtime问题

qq_44224801的博客 747

java毕业设计选题大全,题目仅供参考

对于选题比较纠结的同学,参考使用。 springboot vue高校师资管理系统 基于SpringBoot vue家政服务系统 ssm+jsp一家运动鞋店的产品推广网站的设计623 基于java的springboot vue农村土地管理系统 ssm医院门诊挂号系统 【530】基于springBoot mybatis在线编程网 基于Java的ssm汽车客运站管理系统的设计与实现032 ssm+jsp学生档案管理系统 springboot vue高校学生评教系统 基于web的springboot垃圾分类回收系

weixin_2630663675的博客 2万+

CoMP 协同多点传输技术

CoMP CoMP是什么 解决什么问题 有什么缺点 CoMP(Coordinated Multiple Points)协同多点传输,通信术语,LTE-A的重要技术之一。 CoMP传输是指地理位置上分离的多个传输点,协同参与为一个终端的数据(PDSCH)传输或者联合接收一个终端发送的数据(PUSCH),参与协作的多个传输点通常指不同小区的基站。CoMP技术将边缘用户置于几个基站的同频率上,几...

ilean_J的博客 2万+

计算机毕业设计成品展示

【375】基于springboot+mybatis+layui的前后端分离高校教材管理系统java web教材征订管理系统演示视频。【274】基于springboot2+mybatis+thymeleaf+layui整合开发的在线心理咨询管理系统。【321】springboot vue前后端分离的课程管理系统java教务管理系统mysql学生选课教师评分系统。【680】基于springboot+mybatis+layui的前后端分离高校教材管理系统。

weixin_2630663675的博客 9566

分布式光纤传感(DFOS)DTS/DAS/DSS 三合一:10公里管线监测实战与数据解读

本文详细介绍了分布式光纤传感(DFOS)技术在10公里管线监测中的实战应用,通过DTS(温度)、DAS(振动)、DSS(应变)三合一系统,实现对管线健康状态的立体感知。文章涵盖工程部署、数据采集、多物理量数据融合及噪声抑制等关键技术,展示了如何通过一根光纤完成复杂监测任务,显著提升管线安全性和维护效率。

weixin_29168153的博客 315

tanner2019安装教程

tanner2019安装教程 tanner安装包 软件由老师提供,但由于老师给的方法不知怎么回事无法使用就自己找了一些方法,本教程仅提供参考 链接:https://pan.baidu.com/s/1A2O6JuEF8YFbe8bPnD3J6w 提取码:ysif 复制这段内容后打开百度网盘手机App,操作更方便哦 安装过程 1.选择TannerTools_v2019.2-Win64.exe,进行安装。 2.选择安装产品 3.选择目标路径 4.确认安装 5.安装成功,退出。 获取许可过程 1.打开key压缩

weixin_47730560的博客 1万+

wuyun知识库目录

1269.利用Office宏及Powershell的针对性攻击样本分析2016-06-24 1268.SQL注入关联分析2016-06-24 1267.Android安全开发之ZIP文件目录遍历2016-06-23 1266.search-guard 在 Elasticsearch 2.3 上的运用2016-06-23 1265.签名加密破除-burp插件在app接口fuzz中的运用201

Grey的博客 1万+

保姆级教程:用Python和PyTorch复现PTB-XL心电信号分类论文(附完整代码)

本文提供了一份详细的PTB-XL心电信号分类教程,涵盖从数据预处理到模型优化的完整流程。通过PyTorch实现三种深度学习架构(Conv1D、SincNet和熵特征融合网络),并针对医疗AI特有的类别不平衡问题提供解决方案。教程包含可运行的代码示例,帮助开发者快速复现论文结果并应用于实际心电信号分析场景。

weixin_30555125的博客 405

京东价格监控软件开发技术探讨八:如何获取京东商品分类数据

“行业”中某些使用者出于捡漏的目的,希望能监控足够多的商品数据,此时,快捷导入大批量商品数据就是他们关注的话题了 。 杀京东 做最走心的京东价格监控软件 免费开源的价格监控软件 欢迎加入QQ群415014949一起讨论

奥塔在线 7万+

故障诊断知识库建设指南

从数据融合到知识图谱构建,从智能推理引擎开发到动态进化机制落地,故障诊断知识库的建设路径已形成 “数据 - 知识 - 智能” 的闭环体系。随着大模型技术的深度融入,知识库将实现从 “规则驱动” 到 “认知推理” 的跨越 —— 通过自然语言理解解析复杂故障描述、多模态分析融合图像与信号数据、预测性算法推演故障发展趋势,持续提升诊断的精准度与前瞻性。

极昆仑智慧 1232

Codex 自定义模型操作指南:CLI 与桌面客户端双端实操

检查版本 codex --version # 预期输出类似:codex-cli 0.133.0-alpha.1 # 如未安装 npm install -g @openai/codex假设你要接入DeepSeek,在# 临时设置(当前终端会话有效)export DEEPSEEK_API_KEY="sk-你的 DeepSeek API Key"# 永久设置(推荐,写入 shell 配置)

篮球界最会写bug的人;程序猿中打球最菜的人。 454

HDU5706 GirlCat(简单dfs)

HDU5706 GirlCat (简单dfs)Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Problem DescriptionAs a cute girl, Kotori likes playing “Hide and Seek” with cats p

这儿有个bug 721

全球首发48V架构的Cybertruck,到底牛在哪?| 深扒特斯拉高压系统架构

特斯拉Cybertruck作为全球首款标配48V架构的量产车,在电气系统架构上进行了多项创新。首先,它采用以太网连接高压控制器与后域控制器,提升了数据传输效率和智能化水平。其次,Cybertruck引入了Pyro烟火断开装置,用于碰撞时快速断开电池连接,提高安全性。在电流监测方面,特斯拉既保留了传统的Shunt分流器技术,又引入了更先进的磁通门电流传感器,后者具有无温漂、完全隔离等优势。48V供电系统在降低电流损耗方面表现优异,但也面临电弧风险、盐水腐蚀等挑战。Cybertruck的48V系统通过PCS供电

weixin_43199439的博客 1347

hdu 5706

hdu 5706 girlcat 一道典型的深搜题目。 看代码的时候顺便体会深搜的含义,才能更熟练。 #include<iostream>//hdu 5704 深搜 #include<cstdio> #include<string.h> #include<queue> #include<vector> #include<stack&...

AC之炼金术师_博客 376

精雕软件(JDpaint) 5.5 绿色版

精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版精雕软件(JDpaint) 5.5 绿色版

ET2012新版免狗免安装绿色软件

ET2012新版免狗免安祖昂绿色软件。,新界面,新视觉,

【DFS】GirlCat HDU5706

D - GirlCat HDU - 5706 #include &lt;bits/stdc++.h&gt; using namespace std; int dir[4][2]={{0,-1},{-1,0},{0,1},{1,0}}; char ch[1010][1010]; int h,w; int gsum; int csum; void dfs(int i,int j,char c) ...

博客 278

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

hdu 5706 GirlCat(dfs)

GirlCat Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 88    Accepted Submission(s): 71 Problem Description As a cute girl, Kotori

ZAQ的博客 747

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

HDU5706 GirlCat【DFS】

  GirlCat   Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1074    Accepted Submission(s): 673     Problem Description As a cute girl, ...

海岛Blog 3379

HDU 5706 GirlCat DFS解决

HDU 5706 GirlCat DFS

淘萄桃的博客 780

hdu 5706 GirlCat【暴力DFS】

GirlCat Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 50    Accepted Submission(s): 42 Problem Description As a cute girl, Kotori likes

mengxiang000000 1239

hdu 5706 GirlCat(DFS)

Problem Description As a cute girl, Kotori likes playing Hide and Seek'' with cats particularly. Under the influence of Kotori, many girls and cats are playingHide and Seek” together. Koroti shots a

跟随内心的渴望 454

HDU 5706(GirlCat)DFS or BFS

题目链接:https://vjudge.net/problem/HDU-5706题意:输入一个N*M的图,判断里面有多少个连续的Girl和cat,可以沿上下左右四个方向。直接DFS或BFS就行。#include&lt;bits/stdc++.h&gt; #define maxn 1000010 #define LL long long using namespace std; int dx[4]=...

Eknight123的博客 321

HDU - 5706 GirlCat(dfs)

GirlCatTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1348    Accepted Submission(s): 829Problem DescriptionAs a cute girl, Kotori likes playin...

柳予欣的三味书屋~ 457

DFS专题_2017CCPC女生赛E题_HDU5706 GirlCat

vj链接 题意: 求所给的n行m列又小写字母组成的图里,能组成多少个不同的girl和cat字符串(有一个字母的位置不同就算不同),只能往上下左右走。dfs就可以,1A~ 代码如下: #include &lt;iostream&gt; #include &lt;cstdio&gt; #include &lt;algorithm&gt; #include &lt;vector&gt; #i...

LATTE 363

HDU-5706(DFS)

题目链接:acm.hdu.edu.cn/showproblem.php?pid=5706 GirlCat Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 1823 Accepted Submission(s): 1091 Probl...

qq_40739219的博客 266

HDU5706 -GirlCat

GirlCat Problem Description As a cute girl, Kotori likes playing “Hide and Seek” with cats particularly. Under the influence of Kotori, many girls and cats are playing “Hide and Seek” together. Koroti shots a photo. The size of this photo is n×m, each pi

qq_45869639的博客 268
上一篇: HDU - 5704 Luck Competition(二分)
下一篇: HDU - 5707 Combine String(DP)
信鸦
博客等级 码龄10年 10粉丝 133原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值