编程介的小学生 2018-11-27 11:36 采纳率: 20.5%
浏览 523
已采纳

用C语言编写五子棋算法计算的问题,怎么解决????

Problem Description
The ACM Team of WHU is planning an online AI arena for Go-bang (Five in a Row). Now, we need some help.

We all know the famous game "Five in a Row". It is traditionally played with go pieces (black and white stones) on a go
board (15x15 intersections). The winner is the first player to get an unbroken row of five stones horizontally, vertically, or
diagonally.

We now have an uncompleted game, that is to say, yet no one won. You are required to tell us that whether the next player
could win within one step or not.

Input
The input consists of multiple test cases. The first line of input contains an integer T, which is the number of test cases.

Each test case is a 15 * 15 go board, 'B' represent for a black stone while 'W' for white ones. '.' represents cross with no
stone represented by 0.

[Technical Specification]
T is an integer, and T <= 20.
The number of white stones is either equal or 1 less than the number of black stones.
There is at least ONE '.' in each test case.
Test cases are separated by ONE empty line.
You can assume that black player goes first.

Output
For each test case, print a single line containing the result. If the next player could win within one step, display 'YES',
otherwise, display 'NO'.

Sample Input
2
........W......
..W......W...B.
.W....B........
.W.......W.....
..BB....W......
...B...........
....B........WW
...........B...
....W..........
.W..B.B....WBB.
BW........B.W.B
...............
W.....BB.W....W
B..B.W.BB....B.
........WW.....

...B...W..BBW..
W..WBW..W...B..
...W..WBW......
.....BWW..B.B..
..BW.B.B..W....
B..W..WBW......
B......B......W
B.B...B....W...
....B.WB...B...
B.W............
.....WW...B....
..B.....B...W.W
.W.........WBW.
B..............
..W.B...W..W..B

Sample Output
NO
YES

  • 写回答

1条回答 默认 最新

  • threenewbee 2019-02-05 20:53
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 fluent的在模拟压强时使用希望得到一些建议
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用
  • ¥15 Web.config连不上数据库
  • ¥15 我想付费需要AKM公司DSP开发资料及相关开发。
  • ¥15 怎么配置广告联盟瀑布流
  • ¥15 Rstudio 保存代码闪退