The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | May 2017 |
| Last Sign in: | 398 Weeks Ago, 4 Days Ago |
| Questions Answered: | 66690 |
| Tutorials Posted: | 66688 |
MCS,PHD
Argosy University/ Phoniex University/
Nov-2005 - Oct-2011
Professor
Phoniex University
Oct-2001 - Nov-2016
Long long ago, there is a magic board. The magic board has N*N cells: N rows and N columns. Every cell contains one integer, which is 0 initially. Let the rows and the columns be numbered from 1 to N.
There are 2 types of operations can be applied to the magic board:
And your girlfriend sometimes has an interest in the total number of the integers 0s on some row or column.
The first line of input contains 2 space-separated integers N and Q. They indicate the size of the magic board, and the total number of operations and queries from the girlfriend.
Then each of the next Q lines contains an operation or a query by the format mentioned above.
For each query, output the answer of the query.
1 = N, Q = 500000 (5 * 105)
1 = i = N
x ? {0, 1} (That is, x = 0 or 1)
Input: 3 6 RowQuery 1 ColSet 1 1 RowQuery 1 ColQuery 1 RowSet 1 0 ColQuery 1 Output: 3 2 0 1
At first, the magic board is
000
So the answer of first query "RowQuery 1" is 3.
After the "ColSet 1 1", the board becomes
column 1 | V 100 100 100
So the answer of the second query "RowQuery 1" is clearly 2, since the cell (1,1) became 1. And the answer of the third query "ColQuery 1" is 0.
Finally, apply the operation "RowSet 1 0", the board has changed to
000 100 100
From this board, the answer of the last query "ColQuery 1" should be 1.
Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll