英语题翻译19

Gap | JXNUOJ

Let's play a card game called Gap.
You have 28 cards labeled with two-digit numbers. The first digit (from 1 to 4) represents the suit of the card, and the second digit (from 1 to 7) represents the value of the card.
First, you shu2e the cards and lay them face up on the table in four rows of seven cards, leaving a space of one card at the extreme left of each row. The following shows an example of initial layout.
Next, you remove all cards of value 1, and put them in the open space at the left end of the rows: "11" to the top row, "21" to the next, and so on.
Now you have 28 cards and four spaces, called gaps, in four rows and eight columns. You start moving cards from this layout.
At each move, you choose one of the four gaps and fill it with the successor of the left neighbor of the gap. The successor of a card is the next card in the same suit, when it exists. For instance the successor of "42" is "43", and "27" has no successor.
In the above layout, you can move "43" to the gap at the right of "42", or "36" to the gap at the right of "35". If you move "43", a new gap is generated to the right of "16". You cannot move any card to the right of a card of value 7, nor to the right of a gap.
The goal of the game is, by choosing clever moves, to make four ascending sequences of the same suit, as follows.
Your task is to find the minimum number of moves to reach the goal layout.

The input starts with a line containing the number of initial layouts that follow.
Each layout consists of five lines - a blank line and four lines which represent initial layouts of four rows. Each row has seven two-digit numbers which correspond to the cards.

For each initial layout, produce a line with the minimum number of moves to reach the goal layout. Note that this number should not include the initial four moves of the cards of value 1. If there is no move sequence from the initial layout to the goal layout, produce "-1".

翻译:

让我们玩一个叫做 Gap 的纸牌游戏。你有 28 张卡片,上面标有两位数字。 第一个数字(从 1 到 4)代表卡片的花色,第二个数字(从 1 到 7)代表卡片的价值。首先,你洗牌并将它们正面朝上放在桌子上,分成四排七张牌,在每排的最左边留出一张牌的空间。 下面显示了初始布局的示例。接下来,你移除所有值为 1 的卡片,并将它们放在行左端的空白处:“11”到顶行,“21”到下一行,依此类推。现在你有 28 张卡片和 4 个空格,称为间隙,分为 4 行和 8 列。 您开始从此布局中移动卡片。在每一步中,您选择四个空白中的一个,并用空白左侧邻居的继任者填补它。 一张牌的继任者是同一花色中的下一张牌,如果它存在的话。 例如“42”的后继是“43”,而“27”没有后继。在上述布局中,您可以将“43”移动到“42”右侧的间隙,或将“36”移动到间隙 在“35”的右边。 如果移动“43”,则会在“16”的右侧生成一个新的间隙。 您不能将任何牌移动到价值 7 的牌的右侧,也不能移动到缺口的右侧。游戏的目标是通过选择巧妙的移动,做出相同花色的四个升序,如下所示。您的任务是找到达到目标布局的最少移动次数。

输入以包含随后初始布局数量的行开始。每个布局由五行组成 - 一个空白行和四行代表四行的初始布局。 每行有七个与卡片相对应的两位数。

对于每个初始布局,生成一条具有最少移动次数的线以达到目标布局。 请注意,此数字不应包括价值为 1 的牌的最初四次移动。如果从初始布局到目标布局没有移动顺序,则产生“-1”。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值