#P1322. Happy Patting
Happy Patting
Happy Patting
题目描述
The "Happy Patting" game is to arrange the children into rows, with people in each row. When the game starts, each child will receive a digital command on his/her mobile phone simultaneously: for forward, for backward, for left, and for right. The children must follow the command to pat the children in the specified direction. How many children are patted by more than one friend? Note: In the plane diagram, the top of a grid is "front" and the bottom is "back". Children in the corners may pat the air, which is also allowed.
输入格式
Each input file contains one test case. The first line gives positive integers and (,), which are the number of rows and the number of people in each row, respectively. Then lines follow, each contains numbers, which represent the digital commands received by the children at the corresponding position. All the numbers in a line are separated by a space.
输出格式
For each test case, print in a line the number of children who are patted by more than one friend.
样例 #1
样例输入 #1
3 5
1 2 3 4 1
4 1 4 3 3
3 2 1 1 3
样例输出 #1
4