割草...(维护数据)

这篇博客讨论了一个关于农田除草的数学问题。在n×m的网格中,每个单元格的草以特定速度生长,操作者可以按时间顺序割掉一整行或整列的草。博客介绍了如何计算在一系列割草操作后总共割掉的草的数量,并提供了样例解释和解决方案。
摘要由CSDN通过智能技术生成

做到一个维护时间的,看到别人的代码感觉太神奇了,写个blog记录一下…

Problem H. Hay Mower
Input file:
Standard Input Time limit: 2 seconds
Output file: Standard Output Memory limit: 256 megabytes
Are you tired of city life? Have you ever had illusions of pastoral peace? The clean atmosphere, the
closeness to nature and the gentle pace of living, all made Setsuna yearn for the pastoral life more.
In order to experience the simple pastoral life, Setsuna has moved to Star Valley and started her farming
journey.
Soon, she discovers the problem: overgrown weeds are harming her farm. In Chinese, we call it ”Sheng
Cao”. She realized that weeding should be put at the top priority.

The farm can be described as an n × m matrix. The growth rate of weed in row i and column j is
denoted as ai,j , indicating that the weed will grow ai,j units every beginning of the moment. At the
end of moment 0, there is no weed on the farm.
Setsuna will use mower k times, where the i-th use occurs at the end of moment ti
. Each use of the
mower completely removes weeds in a row or column.
Setsuna wonders how many units of weed she will remove.
The answer might be very large, so please output the desired answer modulo 998244353.
Input
The first line contains three integers n, m, k(1 ≤ n, m ≤ 500, 1 ≤ k ≤ 3 × 105
).
The next n lines contains m integers each, where the j-th integer of the i-th line is ai,j (0 ≤ ai,j ≤ 1018).
The i-th of the next k lines contains one character and two integers.
• r xi ti - Setsuna clears the weeds in row xi at the end of moment ti
.
• c yi ti - Setsuna clears the weeds in column yi at the end of moment ti
.
It is guaranteed that 1 ≤ xi ≤ n, 1 ≤ yi ≤ m, 1 ≤ ti ≤ 1018 hold for 1 ≤ i ≤ k and ti
is strictly increasing.
Output
Output one integer indicating the answer modulo 998244353.

Samples
Standard Input Standard Output
2 2 3
1 2
3 4
r 1 5
c 2 6
r 1 7
45

3 4 1
1 2 3 4
5 6 7 8
9 10 11 12
r 1 1000000000000000000
172998509
Note
Sample 1:
At the end of moment 0, the farm looks like
[0 0
0 0]
At the end of moment 5, Set

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值