-->
当前位置:首页 > 题库

PROGRAMMING:Triple table addition

Luz5年前 (2021-05-10)题库385
Two sparse matrices A and B of the same order are represented by triples respectively. Programming c = a + B requires C to also be represented by triples.
###Input format:
The first line is two positive integers m and n not more than 1000, which represent the number of non-zero elements of matrix A and B, that is, the length of triple table of a and B. The next M rows represent the node information of M triples of matrix a respectively, and 3 integers in each row represent the row number, column number and value of each triplet node. The next n rows represent the node information of N triples of matrix B, and 3 integers in each row represent the row number, column number and value of each triplet node.
###Output format:
Output the triple table of matrix C, each triple node has a row, the elements in the same row are separated by spaces, and there is no space after the last element in each row.
###Input example:
```in
2 3
1 2 3
2 1 3
1 2 1
2 1 3
2 3 6
```
###Output example:
```out
1 2 4
2 1 6
2 3 6
```







answer:If there is no answer, please comment