寒假学习第八天

又是下雨加吃席的一天,就是饭半生半熟的  害~

今天也随缘抽一个吧

                                           A Knight's Journey

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.

翻译:

​                                                          骑士的旅行

背景​:
骑士对一次又一次地看到同样的黑白方块感到厌烦,于是决定去旅行。
全世界当一个骑士移动时,它是一个方向上的两个正方形和一个垂直于此的正方形。骑士的世界就是他生活的棋盘。我们的骑士生活在一个比普通的8*8棋盘面积更小的棋盘上,但它仍然是长方形的。你能帮助这位冒险的骑士制定旅行计划吗?


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

输入:

输入从第一行的正整数n开始。以下行包含n个测试用例。每个测试用例由一条带有两个正整数p和q的单行组成,因此1<=p*q<=26。这表示一个p*q棋盘,其中p表示有多少不同的平方数1,p存在,q描述了存在多少不同的方字母。这是拉丁字母表中的第一个q字母:A。

输出:

每个场景的输出都以一行开头,其中包含“场景i:”,其中i是从1开始的场景编号。然后打印一行,其中包含按字典顺序排列的第一条路径,该路径访问棋盘上的所有方块,骑士的动作后跟一条空行。路径应该通过连接访问的方块的名称在单行上给出。每个正方形名称由一个大写字母和一个数字组成。
如果不存在这样的路径,您应该输出不可能。

明天继续吃席》》》233333​
 

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值