A-1 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: 1 for forward, 2 for backward, 3 for left, and 4 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 2 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.
题目示例数据
3 5
1 2 3 4 1
4 1 4 3 3
3 2 1 1 3
4