Submit | All submissions | Best solutions | Back to list |
ADAPOWER - Ada and Power |
Ada the Ladybug got a new homework today. She was attending algebra class and teacher was lecturing about various utilizations of matrix multiplication. He wanted to teach his students about the power of matrix, so he gave them following homework:
Students were given a matrix followed be multiple queries. The query of first kind is adding a number to each element of a rectangular region of their matrix. In the query of second kind, a matrix is given and students are asked, whether it is the second power of actual matrix.
Can you help Ada to solve her homework?
Input
The first line contains two integers 1 ≤ N ≤ 150 , the size of square matrix and 1 ≤ Q ≤ 200 , the number of queries.
Each of the next N lines contains N integers 0 ≤ Ax, y ≤ 100, the element on xth,yth coordinate of matrix.
Then Q queries follows:
The query of first kind is 1 followed five integers 0 ≤ x, y ≤ X, Y < N, specifying the part, to which the number will be added, and number 0 ≤ V ≤ 100, the value which will be added.
The query of second kind is 2 followed by N lines containing N integers, which are supposed to be the second power of actual matrix.
Output
For each query of second kind, print either yes, if given matrix is second power of actual state of matrix or no in the other case.
Example Input
2 5 1 2 2 1 2 5 4 4 5 2 4 5 5 4 1 0 1 1 1 1 2 7 9 6 10 2 5 4 4 5
Example Output
yes no yes no
Example Input 2
5 10 66 60 69 84 23 69 81 94 91 66 24 38 35 65 28 31 27 91 57 11 4 5 40 0 71 1 3 0 4 0 79 2 21301 13825 21173 20277 9967 27887 17060 26586 24464 15252 14519 7743 13488 11454 6743 18490 13839 18940 20861 8268 12676 7260 10437 10027 8400 1 1 0 4 2 100 1 2 4 3 4 37 1 2 2 2 2 1 1 0 2 0 3 4 2 46237 38485 46414 21029 16080 96987 88160 100456 49140 37497 73915 66266 75834 36015 28535 79761 74224 83550 45701 31771 60176 56760 62709 34759 25280 2 46237 38485 46414 21029 16080 96987 88160 100456 49140 37497 73915 66266 75835 36015 28535 79761 74224 83551 45701 31771 60176 56760 62709 34759 25280 2 46237 38486 46414 21028 16080 96987 88160 100456 49140 37497 73915 66265 75835 36016 28535 79761 74224 83551 45701 31771 60176 56760 62709 34759 25280 2 46237 38485 46414 21029 16080 96987 88160 100456 49140 37497 73915 66266 75835 36015 28535 79761 74224 83551 45701 31771 60176 56760 62709 34759 25280
Example Output 2
no no yes no yes
Added by: | Morass |
Date: | 2017-06-14 |
Time limit: | 0.5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All |