← 返回 scale.ai 的题目列表Matrix State Update (Variant of Game of Life)
类型:online_judge
Given an m x n integer matrix board where each cell represents a discrete state (e.g., 0/1), update the board by applying a provided set of transition rules based on each cell's neighbor count. The update must be simultaneous (i.e., computing the next state should not be affected by updates within the same iteration).
Implement an in-place one-step update and output the resulting matrix.
Note: The implementation pattern is the same as LeetCode 289 “Game of Life”, but the exact transition rules are specified by the interviewer.
Input
Line 1: two integers m n
Next m lines: n integers describing board
Output
The updated matrix in the same format (m lines, n integers)
Constraints
1 <= m, n <= 200
board[i][j] is a small integer (typically 0/1, as specified)
Must update simultaneously; in-place solutions may use bit encoding / temporary markers
Example
(Example depends on the interviewer-provided rules.)
Example
Input
1 1
0
Output
0