1649 - 第四届“恒生杯”程序设计大赛决赛 G
Time Limit : 1 Second
Memory Limit : 128 MB
Submission: 12
Solved: 3
- Description
Given a 2D board containing 'X' and 'O', capture all regions surrounded by 'X'.
A region is captured by flipping all 'O's into 'X's in that surrounded region.
For example,
X X X X
X O O X
X X O X
X O X X
After running your function, the board should be:
X X X X
X X X X
X X X X
X O X X
- Input
The first line contains the number of test cases T. T test cases follow. Each case contains an integer N and M on the first line, followed by N lines, each line contains M characters, each character is ‘X’ or ‘O’.
1 <= T <= 100
1 <= N * M <= 100000
- Output
Output T boards, one for each test case, the captured 2D board.
- sample input
- sample output
- hint
- source