传统题 1000ms 256MiB

A-1 Happy Patting

该比赛已结束,您无法在比赛模式下递交该题目。您可以点击“在题库中打开”以普通模式查看和递交本题。

The "Happy Patting" game is to arrange the children into nn rows, with mm 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 nn and mm ( 2n,m1002\le n, m \le 100 ), which are the number of rows and the number of people in each row, respectively.
Then nn lines follow, each contains mm 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

PAT2024秋季重现赛

未参加
状态
已结束
规则
IOI
题目
11
开始于
2025-8-3 14:00
结束于
2025-8-3 17:30
持续时间
3.5 小时
主持人
参赛人数
51