Superbot ZOJ - 3865 (BFS)

CentOS 7下Oracle 11G RAC静默安装避坑指南:从网络规划到共享存储配置全流程 本文详细介绍了在CentOS 7环境下进行Oracle 11G RAC静默安装的全流程,包括网络规划、共享存储配置和系统参数调优等关键步骤。特别针对静默安装过程中的常见问题提供了实用的避坑指南和优化建议,帮助技术人员高效完成企业级数据库部署。 阅读详情

Superbot

ZOJ - 3865

Superbot is an interesting game which you need to control the robot on an N*M grid map.

As you see, it's just a simple game: there is a control panel with four direction left (1st position), right (2nd), up (3rd) and down (4th). For each second, you can do exact one of the following operations:

  • Move the cursor to left or right for one position. If the cursor is on the 1st position and moves to left, it will move to 4th position; vice versa.
  • Press the button. It will make the robot move in the specific direction.
  • Drink a cup of hot coffee and relax. (Do nothing)

However, it's too easy to play. So there is a little trick: Every P seconds the panel will rotate its buttons right. More specifically, the 1st position moves to the 2nd position; the 2nd moves to 3rd; 3rd moves to 4th and 4th moves to 1st. The rotating starts at the beginning of the second.

Please calculate the minimum time that the robot can get the diamond on the map.

At the beginning, the buttons on the panel are "left", "right", "up", "down" respectively from left to right as the picture above, and the cursor is pointing to "left".


Input

There are multiple test cases. The first line of input contains an integer T indicating the number of test cases. For each test case:

The first line contains three integers N, M (2 <= N, M <= 10) and P (1 <= P <= 50), which represent the height of the map, the width of the map and the period that the panel changes, respectively.

The following lines of input contains N lines with M chars for each line. In the map, "." means the empty cell, "*" means the trap which the robot cannot get in, "@" means the initial position of the robot and "$" means the diamond. There is exact one robot and one diamond on the map.

Output

For each test case, output minimum time that the robot can get the diamond. Output "YouBadbad" (without quotes) if it's impossible to get the diamond.

Sample Input
4
3 4 50
@...
***.
$...
5 5 2
.....
..@..
.*...
$.*..
.....
2 3 1
*.@
$.*
5 5 2
*****
..@..
*****
$....
.....
Sample Output

12
4
4
YouBadbad

Hint

For the first example:
0s: start
1s: cursor move right (cursor is at "right")
2s: press button (robot move right)
3s: press button (robot move right)
4s: press button (robot move right)
5s: cursor move right (cursor is at "up")
6s: cursor move right (cursor is at "down")
7s: press button (robot move down)
8s: press button (robot move down)
9s: cursor move right (cursor is at "left")
10s: press button (robot move left)
11s: press button (robot move left)
12s: press button (robot move left)

For the second example:
0s: start
1s: press button (robot move left)
2s: press button (robot move left)
--- panel rotated ---
3s: press button (robot move down, without changing cursor)
4s: press button (robot move down)

For the third example:
0s: start
1s: press button (robot move left)
--- panel rotated ---
2s: press button (robot move down)
--- panel rotated ---
3s: cursor move left (cursor is at "right")
--- panel rotated ---
4s: press button (robot move left)


有t组输入

每组输入n, m, p。表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲)。

然后是地图的输入。其中'@'为起点,'$'为终点,'.'为通路,'*'为不通。

问从起点到终点最少需要多久?

注意!

每一秒有4种操作,注意,不是三种,1. 光标左移,2. 光标右移,3. 按照光标方向行走,4. 不动(尤其是这一个)。

所谓光标左移,右移,因为题目中给出了光标(在图上,共4个方向),每次改变的移动方向只能是当前光标选择的方向的左右两个。而行走只能按照光标所指的方向。

另外每过p秒,方向会变化(初始四个方向的顺序为左右上下,p秒后变成右上下左,再过p秒后变为上下左右)。

code:

#include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
const int N = 20;
struct node{
    int x,y,dir,t;
};
int go[4][2] = {{0,-1},{0,1},{-1,0},{1,0}};
int n,m,P;
char mp[N][N];
bool vis[N][N];
bool vvis[N][N][5];
int change(int a){
    switch(a){
    case 0:
        return 3;
    case 1:
        return 0;
    case 2:
        return 1;
    case 3:
        return 2;
    }
}
void bfs(){
    node p;
    bool flag = false;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(mp[i][j] == '@'){
                p.x = i;
                p.y = j;
                flag = true;
                break;
            }
        }
        if(flag) break;
    }
    p.dir = 0;
    p.t = 0;
    vvis[p.x][p.y][p.dir] = 1;
    queue<node>que;
    que.push(p);
    while(!que.empty()){
        p = que.front();
        que.pop();
        int xx = p.x + go[p.dir][0];
        int yy = p.y + go[p.dir][1];
        if(xx >= 0 && xx < n && yy >= 0 && yy < m){
            if(!vis[xx][yy]){
                if(mp[xx][yy] == '.'){
                    vis[xx][yy] = 1;
                    node q;
                    q.x = xx;
                    q.y = yy;
                    q.t = p.t + 1;
                    q.dir = p.dir;
                    if(q.t % P == 0){
                        q.dir = change(q.dir);
                        vvis[xx][yy][q.dir] = 1;
                    }
                    que.push(q);
                }
                else if(mp[xx][yy] == '$'){
                    printf("%d\n",p.t + 1);
                    return;
                }
             }
        }
        if((p.t + 1) % P == 0)
            p.dir = change(p.dir);
        node q;
        q.x = p.x;
        q.y = p.y;
        q.t = p.t + 1;

        q.dir = (p.dir + 1) % 4;
        if(!vvis[q.x][q.y][q.dir]){
            que.push(q);
            vvis[q.x][q.y][q.dir] = 1;
        }
        q.dir = (p.dir + 3) % 4;
        if(!vvis[q.x][q.y][q.dir]){
            que.push(q);
            vvis[q.x][q.y][q.dir] = 1;
        }
        q.dir = p.dir;
        if(!vvis[q.x][q.y][q.dir]){
            que.push(q);
            vvis[q.x][q.y][q.dir] = 1;
        }
    }
    printf("YouBadbad\n");
}
int main(){
    int T;
    scanf("%d",&T);
    while(T--){
        memset(vis,0,sizeof(vis));
        memset(vvis,0,sizeof(vvis));
        scanf("%d%d%d",&n,&m,&P);
        for(int i = 0; i < n; i++){
            scanf("%s",mp[i]);
        }
        bfs();
    }
    return 0;
}

Istio ICA考试之路---2-2 找到dr部分,这部分可以在mirroring里找也可以和题2-1一样在Traffic Management的dr里复制,内容都一样。此题之后都是在cluster-2上操作,所以就不需要再切换了.之后的几题2.1节就忽略掉了。可以看到,80%的流量被镜像到了dev上,实际考试这步可以忽略。看到ex-ip是192.168.126.220。获取gw,把gateways加入到vs配置中。获取istio-ingress的ex-ip。就获得了这样一个模板文件。查看2个pod的日志。 阅读详情

相关推荐

新版MQL语言程序设计:用vscode编写编译调试mt4和mt5程序

使用VScode搭建MT4与MT5开发环境,实现编辑编译调试统一。

超哥量化的博客 6890

ZOJ 3865 Superbot BFS

地图很小,根据题意BFS Superbot Time Limit: 2 Seconds      Memory Limit: 65536 KB Superbot is an interesting game which you need to control the robot on an N*M grid map. As you see, it's just

码代码的猿猿 1457

Qt QChart实战:从零打造一个实时温度监控仪表盘(附完整源码)

本文详细介绍了如何使用Qt QChart模块从零构建一个工业级实时温度监控仪表盘。通过实战案例,展示了波形图的绘制、坐标轴配置、数据流模拟等关键技术,并提供了完整的源码实现,帮助开发者快速掌握Qt在数据可视化领域的应用。

weixin_42537919的博客 250

ZOJ3865:Superbot(BFS)

Superbot is an interesting game which you need to control the robot on an N*M grid map. As you see, it's just a simple game: there is a control panel with four direction left (1st position), right

ACM!荣耀之路! 1323

高质量水下垃圾数据集解析与应用实践

计算机视觉在环保领域的应用日益广泛,其中目标检测技术是关键支撑。通过深度学习模型对水下垃圾进行精准识别,需要高质量标注数据集作为基础。1962幅水下垃圾数据集采用专业预处理流程,包括色彩校正、去雾增强等技术,有效解决了水下图像的光照不均、水体浑浊等典型问题。该数据集覆盖12类常见海洋垃圾,标注错误率低于2%,显著提升了模型训练效果。在工程实践中,该数据集特别适合用于水下机器人实时检测系统和海洋垃圾分布热力图生成等场景,通过优化模型架构和数据增强策略,可实现更高效的环境监测与保护。

weixin_42616115的博客 259

10分钟上手YOLOv11:最强姿态估计模型来了,代码开源,效果炸裂!

【10分钟玩转YOLOv11实时姿态估计】🚀 YOLOv11作为YOLO家族最新成员,在速度、精度和易用性上全面升级,尤其适用于姿态估计等复杂视觉任务。本文带您快速掌握: 1️⃣ 核心概念:姿态估计即识别人体17个关键点(如关节部位)并连接成数字骨架,是智能健身、体感游戏等应用的基础。 2️⃣ 技术优势: 超轻量级(最小仅2.9M参数) 极速推理(GPU仅1.7ms) 高精度(COCO mAP@50-95达50%) 3️⃣ 三步实操: ① 安装:pip install ultralytics ② 准备人物

weixin_41246802的博客 1795

ZOJ 3865 - Superbot(BFS)

题目: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=5477 题意: 给你一个n*m的地图,求出从@走到$的最小时间.使用按钮去控制人走的方向. 四个按钮的初始位置是(左,右,上,下).每p秒按钮会向右移动变成(下,左,右,上). 思路: BFS. vis[x][y][按钮方向][时间] 记录走过的位

Halo 816

详解一典型的反激式开关电源方案

如图,在某系统方案上看到下图所示的单端反激式开关电源方案。

alala120的博客 1万+

【 ZOJ- 3865】Superbot(BFS)

Superbotis an interesting game which you need to control the robot on anN*Mgrid map. As you see, it's just a simple game: there is a control panel with four direction left (1stposition), right ...

__似水流年__的博客 318

GIS坐标系转换以及空间校正和地理配准

许多小伙伴都对坐标系,投影这类问题迷迷糊糊,我之前也一样,现在总结一下。 坐标系的转换1.为什么要进行坐标系的转换?2. 不同坐标系的介绍1.地理坐标系我国常见的地理坐标(1).北京54坐标系(2).西安80坐标系(3).WGS-84坐标系(4).大地2000坐标系2.投影坐标系我国常用的投影坐标系(1) UTM投影(2) 高斯-克吕格投影(3) 兰伯特投影(4) 阿尔伯斯投影投影坐标系的选择3. 坐标系的转换1.已知坐标系之间的转换1.1 两坐标系的参考椭球相同1.2 两坐标系的参考椭球不一致,但是GIS

m0_47258611的博客 8919

KNX智能家居工程设计应用

KNX,是一个起源于欧洲的总线标准,主要应用于家居和楼宇中,对末端电气设备进行总线式的控制,比如照明、空调、地暖、电动窗帘和遮阳设备等等。根据2017年英国著名咨询公司BSRIA的数据报告显示,在中国的智能家居和灯光控制市场,KNX产品的市场份额为各类产品中排名第一,占据了42%的市场份额,远远领先于其他的标准协议。设备中一个继电器表示一路输出,某些功能可能需要用到多个输出,比如1个窗帘AC输出需要占用两路继电器输出,一个继电器用于控制正转,一个用于控制反转,而普通开关输出则需要占用一路继电器输出即可。

hhhh5555666的博客 938

(BFS)Superbot

Superbot Time Limit: 2 Seconds      Memory Limit: 65536 KB Superbot is an interesting game which you need to control the robot on an N*M grid map. As you see, it's just a simple gam

better_life30的专栏 458

ABB机器人与S7-1200PLC实现位置坐标数据发送和接收的具体方法

ABB机器人与S7-1200PLC实现位置坐标数据发送和接收的具体方法

Robot_PLC_HMI_Automation 2924

[bfs] zoj 3865 Superbot

题意: 给一个n*m的图。 '@'代表你的位置,'.'代表空地,'*'代表墙,'$'代表钻石。 在每一秒钟你有四种选择。 1、站着不动。 2、光标往左移动一格。 3、光标往右移动一格。 4、点击光标让自己按光标的方向移动一格。 然后题目还给了一个k,代表每k秒光标整体循环右移一格。 现在问你拿到钻石的最少步数。 思路: 本弱开了一个四维数组判重use[x][y][f][l]

Enmity_Dark 700

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Superbot ZOJ - 3865(BFS)

Superbot 题目链接:ZOJ - 3865题意:一个N*M地图, 可以通过光标移动机器人, 使之找到钻石(@表示机器人初始位置, $表示钻石位置, *表示障碍, .表示空地),每p秒光标自动右移, 每秒一个操作,四个操作:1&gt; 按...

Sirius_han的博客 227

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

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

BFS+模拟 ZOJ 3865 Superbot

题目传送门 1 /* 2 BFS+模拟:dp[i][j][p] 表示走到i,j,方向为p的步数为多少; 3 BFS分4种情况入队,最后在终点4个方向寻找最小值:) 4 */ 5 #include <cstdio> 6 #include <iostream> 7 #include <al...

weixin_34392843的博客 66

ZOJ - 3865 Superbot 【BFS】

题目链接 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3865 思路 一个迷宫题 但是每次的操作数和普通的迷宫题不一样 0.按下按钮 即向当前方向盘的方向前进一格 1.往左移动方向盘 2.往右移动方向盘 3.不动 然后记录时间 易知,可以从四个方向到达终点,最后从这四个方向找最小值就是答案 当然要判...

Dup4'Blog 255

ZOJ 3865 Superbot(BFS)

题目链接:http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3865 题意:给你一个n*m的地图,求出从@走到$的最小时间.使用按钮去控制机器人走的方向; 四个按钮的初始位置是:左右上下,每隔P秒按钮就会向右移动,变成:下左右上、上下左右、右上下左…… 思路: 为了简化按钮的移动步骤,我们直接用二进制给四个位置标记,1

Yedl的专栏 704

ZOJ 3865 Superbot(BFS水题)

比赛的时候题意理解错了,不想多说什么了。。 水题一道,,给你四个按钮,每次你可以选择不动,左右移动按钮,按钮每P秒右移一次,,水啊 #include "stack" #include "cstdio" #include "iostream" #include "cmath" #include "set" #include "sstream" #include "cctype" #

潮鸣り 401

zoj 3865 Superbot(BFS)

Superbot Time Limit: 2 Seconds      Memory Limit: 65536 KB Superbot is an interesting game which you need to control the robot on an N*M grid map. Superbot是需要你在一个N*M的网格地图里控制机器人的有趣游戏。

24小时的程序员 672

zoj.3865.Superbot(bfs + 多维dp)

SuperbotTime Limit:2 Seconds Memory Limit:65536 KB Superbotis an interesting game which you need to control the robot on anN*Mgrid map. As you see, it's just a simple game: there is a co...

weixin_30379911的博客 83

浙江大学2015年校赛F题 ZOJ 3865 Superbot BFS 搜索

不知道为什么比赛的时候一直想着用DFS 来写 一直想剪枝结果还是TLE = = 这题数据量不大,又是问最优解,那么一般来说是用 BFS 来写 int commandi[4] = {1, 2, 3, 4}; 我定义了一个方向数组,其实题目意思中的,指针移动还有操作版的变化本质上都是指针的移动 在此只需要 额外定义一个变量 cur 在数组 commandi 中循环移动即...

weixin_30540691的博客 196

zoj 3865 Superbot BFS 根据会动的↑↓←→让机器人找钻石

Superbot Time Limit: 2 Seconds Memory Limit: 65536 KB   Superbot is an interesting game which you need to control the robot on an N*M grid map. As you see, it's just a simple game: t

我的指针和我一样找不到对象 1336

ZOJ3865:Superbot(BFS) The 15th Zhejiang University Programming Contest

一个有几个小坑的bfs 题目很长,但并不复杂,大概总结起来有这么点。 有t组输入 每组输入n, m, p。表示一个n*m的地图,每p秒按键会右移一次(这个等会儿再讲)。 然后是地图的输入。其中'@'为起点,'$'为终点,'.'为通路,'*'为不通。 问从起点到终点最少需要多久? 一眼看去,裸的bfs嘛,10*10的地图,简单! 不过还是连错4次…… 注意! 每一秒有4种操作...

weixin_30894583的博客 106

ZOJ 3865 Superbot

解题思路: 简单的bfs, 记录一下当前的键盘状态。 #include #include #include #include #include #include #include #include #include #include #define ll long long using namespace std; int Move[][2] = { {0, -1}, {0

蘑菇--走在通往梦想的道路上。 561
上一篇: GCD Expectation ZOJ - 3868 (容斥原理+快速幂)
下一篇: Teams Formation CodeForces - 878B (思维+模拟)
Guuuuuu老师儿
博客等级 码龄9年 259粉丝 718原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值