acm 试题

来源:百度知道 编辑:UC知道 时间:2024/05/18 01:02:04
Link Link Look
TimeLimit : 1 Second Memorylimit : 32 Megabite
Totalsubmit : 0 Accepted : 0

A single player game is played on a grid chessboard with some colored beads on. In each round, the player can click on two grids of the chessboard. If the two grids both have beads of the same color, and a line with no more than two turns could be drawn to connect the two beads, the two beads will both disappear from the chessboard. Note that the line must not pass through any other beads.

Figure 1: Valid clicks that will erase the two beads
Given the information of a chessboard and the player's clicks in each round, you are required to calculate how many beads will disappear.

Input
The input consists of several test cases. The first line of each case contains two numbers N and M (1 <= N, M <= 100), indicating the dimensions of the chessboard. Then N lines follow, each represents a row of the chessboard. The positive numbers rep

numbers N and M (1 <= N, M <= 100), indicating the dimensions of the chessboard. Then N lines follow, each represents a row of the chessboard. The positive numbers represent different colors ofnumbers N and M (1 <= N, M <= 100), indicating the dimensions of the chessboard. Then N lines follow, each ujyuy nudfuef kldfneuf bfbwefbbwef ebyfierewryir ygriofbreknfebf ybufebfyrbrf byubq8wye8qpeqqhew9qye7qwy7ewqhxhjwdhw g7rwq8rg7weqrihudhwd78wq9dw7hwq79d juiasjiqsjqjq8jshdw h7gwrq8rgq8wdhqdqwd7qhd7q8dh we7hqe7h8qwehnd8q7wedhwqd8nuds