Subscribed unsubscribe Subscribe Subscribe

Takefumi Yamamura's blog

This blog is for my memorandum.

Takefumi Yamamura's b!og

This blog is for my memorandum

srm707 easy Cross

TopCoder

problem

There is a rectangular board that is divided into n rows by m columns of cells. Each cell is either black or white. You are given the description of the board in the board. Each character in board represents one cell. More precisely, the character board[i][j] represents the cell at coordinates (row i, column j). The character ‘#’ represents a black cell, the character ‘.’ is a white cell. Formally, there is a cross centered at (x, y) if the following five cells are all black: (x, y), (x+1, y), (x-1, y), (x, y-1), and (x, y+1). Note that other cells adjacent to the cross may also be black, it is still a valid cross.

Return “Exists” if there is at least one cross on the given board. Otherwise, return “Does not exist”. Note that the return value is case-sensitive.

code