8442: Grazing Patterns

内存限制:128 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:1 通过:1

题目描述

Due to recent budget cuts, FJ has downsized his farm so that the grazing area for his cows is only a 5 meter by 5 meter square field! The field is laid out like a 5x5 grid of 1 meter by 1 meter squares, with (1,1) being the location of the upper-left square, and (5,5) being the location of the lower-right square: (1,1) (1,2) (1,3) (1,4) (1,5) (2,1) (2,2) (2,3) (2,4) (2,5) (3,1) (3,2) (3,3) (3,4) (3,5) (4,1) (4,2) (4,3) (4,4) (4,5) (5,1) (5,2) (5,3) (5,4) (5,5) Every square in this grid is filled with delicious grass, except for K barren squares (0 <= K <= 22, K even), which have no grass. Bessie the cow starts grazing in square (1,1), which is always filled with grass, and Mildred the cow starts grazing in square (5,5), which also is always filled with grass. Each half-hour, Bessie and Mildred finish eating all the grass in their respective squares and each both move to adjacent grassy squares (north, south, east, or west). They want to consume all the grassy squares and end up in exactly the same final location. Please compute the number of different ways this can happen. Bessie and Mildred always move onto grassy squares, and they never both move onto the same square unless that is the very last grassy square remaining.

由于最近的预算削减,农夫约翰缩小了农场规模,使他的奶牛的牧场面积只有 5 米见方。



牧场区域可以看作一个 5×5 的方格矩阵,每个方格大小为 1×1。



其中 (1,1) 是左上角方格的位置,而 (5,5) 是右下角方格的位置:



(1,1) (1,2) (1,3) (1,4) (1,5)

(2,1) (2,2) (2,3) (2,4) (2,5)

(3,1) (3,2) (3,3) (3,4) (3,5)

(4,1) (4,2) (4,3) (4,4) (4,5)

(5,1) (5,2) (5,3) (5,4) (5,5)

除了 K 个贫瘠的方格区域没有长草以外,其他方格内都充满了可口的青草。



奶牛贝茜从方格 (1,1) 开始吃草,奶牛米尔德瑞德从方格 (5,5) 开始吃草,这两个方格内一定有草。



每半个小时,两头奶牛就会吃光各自所在方格内的草,并移动到相邻(东、南、西、北)的有草的方格中。



她们想吃光牧场中所有的草,并最终到达完全相同的位置。



请计算发生这种情况的不同方式的数量。



两牛总是会移动到有草的方格内,除非是最后一个剩下的有草方格,否则她们永远都不会走到同一格子内。




输入格式

第一行包含整数 K。



接下来 K 行,每行包含两个整数 i,j 用来描述一个没有长草的方格的位置 (i,j)。

输出格式

输出两牛吃光所有草,并最终到达同一位置的所有可能方式的数量。

输入样例 复制

4
3 2
3 3
3 4
3 1

输出样例 复制

1

数据范围与提示

初始时,牧场如下:



b  .  .  .  .



.  .  .  .  .



x  x  x  x  .



.  .  .  .  .



.  .  .  .  m

其中,x 为不长草的方格区域,b 为贝茜的开始区域,m 为米尔德瑞德的开始区域。



唯一一种可能的方式如下所示,两牛在 (3,5) 相遇:



b  b--b  b--b

|  |  |  |  |

b--b  b--b  b

            |

x  x  x  x b/m

            |

m--m--m--m--m

|

m--m--m--m--m