#P6974. [NEERC 2015] Adjustment Office
[NEERC 2015] Adjustment Office
题目描述
Garrison and Anderson are working in a company named “Adjustment Office”. In competing companies workers change the reality, in this company they try to predict the future.
They are given a big square board . Initially in each cell of this board the value of is written ). They know that in the future there will be two types of queries on the board:
- “R ” — sum up all values in row , print the result and set all values in row to zero;
- “C ” — sum up all values in column , print the result and set all values in column to zero.
They have predicted what queries and results there will be. They need to ensure that they have correctly predicted the results. Help them by computing the results of the queries.
输入格式
The first line of the input contains two integers and , ) — the size of the square and the number of queries.
Each of the next lines contains the description of the query. Each query is either “R ” ) or “C ” ).
输出格式
The output file shall contain lines. The - th line shall contain one integer — the result of the - th query.
3 7
R 2
C 3
R 2
R 1
C 2
C 1
R 3
12
10
0
5
5
4
0
提示
Time limit: 1 s, Memory limit: 256 MB.