1.28英文题面翻译

描述

Background
The knight is getting bored of seeing the same black and white squares again and again and has decided to make a journey
around the world. Whenever a knight moves, it is two squares in one direction and one square perpendicular to this. The world of a knight is the chessboard he is living on. Our knight lives on a chessboard that has a smaller area than a regular 8 * 8 board, but it is still rectangular. Can you help this adventurous knight to make travel plans?

Problem
Find a path such that the knight visits every square once. The knight can start and end on any square of the board.

输入

The input begins with a positive integer n in the first line. The following lines contain n test cases. Each test case consists of a single line with two positive integers p and q, such that 1 <= p * q <= 26. This represents a p * q chessboard, where p describes how many different square numbers 1, . . . , p exist, q describes how many different square letters exist. These are the first q letters of the Latin alphabet: A, . . .

输出

The output for every scenario begins with a line containing "Scenario #i:", where i is the number of the scenario starting at 1. Then print a single line containing the lexicographically first path that visits all squares of the chessboard with knight moves followed by an empty line. The path should be given on a single line by concatenating the names of the visited squares. Each square name consists of a capital letter followed by a number.
If no such path exist, you should output impossible on a single line.

OpenJudge - 1490:A Knight's Journey

 翻译

描述

背景
骑士厌倦了一遍又一遍地看到同样的黑白方块,决定开始一段旅程去往世界各地。当一个骑士移动时,它是一个方向上的两格和垂直于这个方向的一格。骑士的世界就是他生活的棋盘。我们的骑士生活在一个比普通8 * 8棋盘面积更小的棋盘上,但它仍然是矩形的。你能帮助这位冒险的骑士制定旅行计划吗?

问题
找到一条让骑士访问每个方块一次的路径。骑士可以在棋盘上的任何方格上开始和结束。

输入

输入的第一行包含一个正整数n。接下来的n行包含n组测试数据,每组测试数据包含单独的一行,有两个正整数p和q,1 <= p * q <= 26,这代表了一个p*q的棋盘,p代表共有多少个不同的数字方格,q代表有多少个不同的字母方格。

输出

每个场景的输出都以包含“Scenario #i:”的行开始,其中i是场景从1开始的编号。然后输出一行包含字典顺序上的第一个路径,该路径访问棋盘上所有有骑士移动的方块,后面跟着空行。路径应该通过连接访问方块的名字在一行上给出。每个方格名由一个大写字母后跟一个数字组成。
如果不存在这样的路径,你应该在一行中输出impossible。

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值