Problem Statement | |||||||||||||
题目简述: 一个无限大平面被划分为由单位方格组成的网格图。 一开始每个方格内的数是1或0。 每秒过后,每个方格内的数 变成他上下左右相邻的、再加上它自己共五个格子 数值的Xor。 输入含有1的那一部分的网格图。 求K秒之后,数值为1的方格有多少个。 数据范围: 输入的网格图大小:n<=50, m<=50 K<=1,000,000,000 Magical Girl Madoka just learned about Conway's Game of Life. She is now thinking about new rules for this game. In the Game of Life, an infinite plane is divided into a grid of unit square cells. At any moment, each cell is either alive or dead. Every second the state of each cell changes according to a fixed rule. In Madoka's version of the game the following rule is used:
You are given the int K and a vector <string> field that describes the initial state of the plane. field describes only some rectangular area of the plane. More precisely, character j of element i of field is 'o' if the cell in the i-th row of the j-th column of the rectangular area is alive, and it is '.' otherwise. Cells which aren't described in field is initially all dead. Return the number of alive cells after K seconds. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Limits | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | You can assume that the result will fit into a signed 64-bit integer. | ||||||||||||
Constraints | |||||||||||||
- | field will contain between 1 and 50 elements, inclusive. | ||||||||||||
- | Each elements of field will contain between 1 and 50 characters, inclusive. | ||||||||||||
- | All elements of field will contain the same number of characters. | ||||||||||||
- | Each character in each element of field will be either 'o' or '.'. | ||||||||||||
- | K will be between 1 and 1,000,000,000, inclusive. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|
This problem statement is the exclusive and proprietary property of TopCoder, Inc. Any unauthorized use or reproduction of this information without the prior written consent of TopCoder, Inc. is strictly prohibited. (c)2003, TopCoder, Inc. All rights reserved.