시간 제한 | 메모리 제한 | 제출 | 정답 | 맞힌 사람 | 정답 비율 |
---|---|---|---|---|---|
3 초 | 512 MB | 3 | 3 | 3 | 100.000% |
You are bored to death during a very long flight. While surfing through the collection of crappy video games provided by the in-flight entertainment system, you have stumbled upon something interesting: the game Battleship! Remember that this is a game for two players played on a 10 by 10 grid; your goal is to position your fleet and try to sink the enemy ships before your own are sunk.
So wouldn't it be fun to try play Battleship while you are flying in a plane? Unfortunately, you'll soon discover that it isn't that much fun after all and the in-flight video game is just a low-budget and buggy clone with several key shortcomings:
Of course, as soon as you have figured out the computer's hardcoded sequence of moves, this makes the game an utter disappointment. Still, you are stuck on the plane and you start to wonder, knowing this sequence, how many ways (if any) do you have to win, i.e. how many ways are there to position the cruiser and survive until the computer gives up?
The input file consists of multiple test cases. The first line of the input file consists of a single integer indicating the number of test cases. Each test case follows. The first line consists of a single integer $0 \leq n \leq 100$ indicating how many times the computer fires before giving up. The next $n$ lines describe the successive squares where the computer fires: the $i$th line consists of two integers $1 \leq r_i \leq 10$ and $1 \leq c_i \leq 10$ giving the row and column of the computer's $i$th shot. It is guaranteed that the computer never fires twice at the same position in its sequence.
For each test case in the input, your program should produce one line consisting of one integer indicating in how many different ways you can position your cruiser at the beginning of the game and survive until the end. The cruiser must be positioned on 3 squares that are vertically adjacent or horizontally adjacent, and you survive unless the computer's sequence hits all the squares where the cruiser is placed.
2 0 10 3 2 4 7 2 2 3 6 3 3 4 9 3 4 3 7 4 8 3 5
160 155
Image rights