F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

King's Visit

Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 65535/32768 K (Java/Others)
Total Submission(s): 130    Accepted Submission(s): 11


Problem Description
In chess, a king can move horizontally, vertically or diagonally to an adjacent cell in each move.
You are given an $8\times 8$ board with some obstacles. The starting position of the king is also given. Your task is to calculate the maximum number of cells that the king can visit, such that:
1.The king never moves to an obstacle.
2.Each cell are visited at most once (the starting position has already been visited at the beginning).
 

Input
The first line is the number of test cases. For each test case, there are $8$ lines and each line contains $8$ characters, in which the letter 'K' is the starting position, a letter 'O' is an obstacle and a '.' is an empty cell. There is an empty line after each test case.
 

Output
For each test case, output a line containing an integer, which is the maximum number of cells that the king can visit.
 

Sample Input
2 .O....O. O......O ........ ...K.... ........ ........ O......O .O....O. .O....O. O...OOO. ......O. ......O. .O....O. .O....O. OOOOOO.. .......K
 

Sample Output
53 33
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-04-20 08:18:18, Gzip enabled