Matrix Addition


Submit solution

Points: 1
Time limit: 2.0s
Python 3 6.0s
Memory limit: 1G

Author:
Problem type

Nic, having sorted all his numbers wants to pack them away nicely in a matrix. Given two square matrices \(A\) and \(B\) of side-length \(N\), add them together to produce a new _compacted_ matrix \(C\), also of side-length \(N\).

Any element in \(C\) can be expressed with the following formula:

\(c_{i,j} = a_{i,j} + b_{i,j}\)

Input Specification

The first line will contain a single integer \(N\), the side-length of \(A, B\) and \(C\).

The next \(N\) lines will contain \(N\) space-separated integers, specifying the element of \(A\).

Then, the next \(N\) lines will contain \(N\) space-separated integers, specifying the elements of \(B\).

Output Specification

You are to output \(N\) lines of \(N\) space-separated integers, the elements of \(C\).

Bounds

This problem includes increasingly difficult sub-problems:

  • 10 points: The sample data provided below
  • 40 points: \(1 \leq N \leq 25\)
  • 50 points: \(1 \leq N \leq 1000\)

For any element of \(A\) or \(B\) in any sub-problem, \(-100 \leq a_{i,j}, b_{i,j} \leq 100\)

Sample Input 1

2
1 0
0 1
0 1
1 0

Sample Output 1

1 1
1 1

Sample Input 2

4
-10 9 8 7
6 5 -4 3
-2 1 0 -1
-11 -23 -34 -45
10 -9 -8 -7
-6 -5 4 -3
2 -1 0 1
11 23 34 45

Sample Output 2

0 0 0 0
0 0 0 0
0 0 0 0
0 0 0 0

Comments

There are no comments at the moment.