编程介的小学生 2017-10-07 07:10 采纳率: 20.5%
浏览 845
已采纳

One-move checkmate

Description

The chess endgame "a king and a queen versus a king" is known to be easy victory for the side that has a queen.

The position in such an endgame is described by the locations of three figures: the white king, the white queen, and the black king. Locations are written in a usual chess notation, constructed from a letter from "a" to "h", which determine vertical line, and the digit from 1 to 8, which determine horizontal line of the location.

Given the position described, you are find a move for the white queen by which the black king will be checkmated, or determine that no such a move exists.
Input

The input contains three two-character locations for the white king, white queen, and black king, in that order, separated by spaces.
The input position is a valid chess position for the white's turn, i.e. all figures occupy different spaces, kings are not located in the neighboring squares, and the black king is not under the check.
Output

Output file must contain the two-character location — destination square for the white queen's move. If checkmating move does not exist, output file must contain the string "no". If there is more than one checkmating move, output the one with the smallest vertical position then with the smallest horizontal postion.
Sample Input

a3 g2 a1
Sample Output

a2

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-10-26 00:35
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?
  • ¥15 乘性高斯噪声在深度学习网络中的应用
  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败