LCC '21 Contest 2 J3 - Grid Sum

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 64M

Author:
Problem type

Stefan, an artificial intelligence enthusiast, has undertaken his greatest challenge yet: to create an AI that can solve any problem in competitive programming.

After many years of research, Stefan has finally created you, a prototype AI, to carry out this task. Now, Stefan would like you to demonstrate your capabilities to him, starting with a simple problem.

You are given an N by M grid with rows numbered 1 to N and columns numbered 1 to M. Your task is to find the sum of all even numbers in even rows or even columns in the grid.

Please solve the problem correctly to avoid disappointing your creator.

Input Specification

The first line will contain two space-separated integers, N and M (1 \leq N, M \leq 500).

The next N lines will each contain M space-separated integers, describing the grid. The jth integer in the ith line will contain the element A_{ij} (1 \le A_{ij} \leq 100).

Output Specification

Output one integer, the sum of all even numbers in even rows or even columns in the grid.

Sample Input

4 3
1 2 3
5 1 2
10 2 4
1 6 5

Sample Output

12

Sample Explanation

Above is a representation of the grid for this sample case. We must consider any even integer in row 2, row 4, or column 2. The answer will be 2 + 2 + 2 + 6 = 12.


Comments

There are no comments at the moment.