HBC216005打铁的箱子,枚举EvilCoordinate题解 (robotmoves)

把回忆走一遍 算法基础篇 43 0
题库丰富多样,涵盖各个领域,全网最全C++题库,让您在练习中不断成长!
Your task is to rearrange the characters in the string in any order, so that the robot will not step onto .

A robot is standing on an infinite 2-dimensional plane. Programmed with a string s1s2⋯sns_1s_2cdots s_ns1​s2​⋯sn​ of length nnn, where si∈{’U’,’D’,’L’,’R’}s_i in {text{'U'}, text{'D'}, text{'L'}, text{'R'}}si​∈{’U’,’D’,’L’,’R’}, the robot will start moving from (0,0)(0, 0)(0,0) and will follow the instructions represented by the characters in the string. More formally, let (x,y)(x, y)(x,y) be the current coordinate of the robot. Starting from (0,0)(0, 0)(0,0), the robot repeats the following procedure nnn times. During the iii-th time: If si=’U’s_i = text{'U'}si​=’U’ the robot moves from (x,y)(x, y)(x,y) to (x,y+1)(x, y+1)(x,y+1); If si=’D’s_i = text{'D'}si​=’D’ the robot moves from (x,y)(x, y)(x,y) to (x,y−1)(x, y-1)(x,y−1); If si=’L’s_i = text{'L'}si​=’L’ the robot moves from (x,y)(x, y)(x,y) to (x−1,y)(x-1, y)(x−1,y); If si=’R’s_i = text{'R'}si​=’R’ the robot moves from (x,y)(x, y)(x,y) to (x+1,y)(x+1, y)(x+1,y). However, there is a mine buried under the coordinate (mx,my)(m_x, m_y)(mx​,my​). If the robot steps onto (mx,my)(m_x, m_y)(mx​,my​) during its movement, it will be blown up into pieces. Poor robot! Your task is to rearrange the characters in the string in any order, so that the robot will not step onto (mx,my)(m_x, m_y)(mx​,my​).

HBC216005打铁的箱子,枚举EvilCoordinate题解
(robotmoves)-第1张图片-东莞河马信息技术
(图片来源网络,侵删)

标签: HBC216005打铁的箱子 枚举EvilCoordinate题解