#include <bits/stdc++.h>
const long long xmod=1e9+7;
using namespace std;
int n,m,q,id;
long long r[1000005],c[1000005],num,sum,ans,mult;
char op;
int main(){
ios::sync_with_stdio(false);
cin >> n >> m >> q;
for (int i=1;i<=n;i++){
r[i]=1;
}
for (int i=1;i<=m;i++){
c[i]=1;
}
for (int i=1;i<=q;i++){
cin >> op >> id >> num;
if (op == 'R') r[id]*=num,r[id]%=xmod;
if (op == 'S') c[id]*=num,c[id]%=xmod;
}
for (long long i=1;i<=m;i++){
sum+=i*c[i]; sum%=xmod;
mult+=c[i]; mult%=xmod;
}
ans=sum*r[1]; ans%=xmod;
for (int i=2;i<=n;i++){
sum+=m*mult; sum%=xmod;
ans+=sum*r[i]; ans%=xmod;
}
cout << ans << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
332 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Correct |
1 ms |
332 KB |
Output is correct |
8 |
Correct |
1 ms |
332 KB |
Output is correct |
9 |
Correct |
1 ms |
332 KB |
Output is correct |
10 |
Correct |
1 ms |
332 KB |
Output is correct |
11 |
Correct |
4 ms |
2764 KB |
Output is correct |
12 |
Correct |
11 ms |
8720 KB |
Output is correct |
13 |
Correct |
1 ms |
844 KB |
Output is correct |
14 |
Correct |
11 ms |
10060 KB |
Output is correct |
15 |
Correct |
11 ms |
9036 KB |
Output is correct |
16 |
Correct |
20 ms |
15992 KB |
Output is correct |
17 |
Correct |
19 ms |
15992 KB |
Output is correct |
18 |
Correct |
20 ms |
16020 KB |
Output is correct |
19 |
Correct |
19 ms |
15988 KB |
Output is correct |
20 |
Correct |
22 ms |
15948 KB |
Output is correct |