#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
using namespace std;
int n, m, k, mod = 1000000007;
long rp[1000000], cp[1000], cs = 0, sum = 0, ans = 0;
int main() {
ios_base::sync_with_stdio(false);
cin >> n >> m >> k;
for (int i = 0; i < n; i++){
rp[i] = 1;
}
for (int i = 0; i < m; i++){
cp[i] = 1;
}
for (int i = 0; i < k; i++){
string r; cin >> r;
int x, y; cin >> x >> y;
if (r.compare("R") == 0){
rp[x-1] *= y; rp[x-1] %= mod;
} else {
cp[x-1] *= y; cp[x-1] %= mod;
}
}
for (int i = 0; i < m; i++){
cs += cp[i];
sum += (i+1)*cp[i]; sum %= mod;
}
for (int i = 0; i < n; i++){
ans += sum*rp[i]; ans %= mod;
sum += cs*m; sum %= mod;
}
cout << ans << endl;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
1 ms |
384 KB |
Output is correct |
3 |
Correct |
1 ms |
384 KB |
Output is correct |
4 |
Correct |
1 ms |
384 KB |
Output is correct |
5 |
Correct |
1 ms |
384 KB |
Output is correct |
6 |
Correct |
1 ms |
384 KB |
Output is correct |
7 |
Correct |
1 ms |
384 KB |
Output is correct |
8 |
Correct |
1 ms |
404 KB |
Output is correct |
9 |
Correct |
1 ms |
384 KB |
Output is correct |
10 |
Correct |
1 ms |
384 KB |
Output is correct |
11 |
Incorrect |
5 ms |
1792 KB |
Output isn't correct |
12 |
Incorrect |
17 ms |
5760 KB |
Output isn't correct |
13 |
Incorrect |
2 ms |
768 KB |
Output isn't correct |
14 |
Incorrect |
19 ms |
7112 KB |
Output isn't correct |
15 |
Incorrect |
17 ms |
5120 KB |
Output isn't correct |
16 |
Incorrect |
28 ms |
8192 KB |
Output isn't correct |
17 |
Incorrect |
28 ms |
8192 KB |
Output isn't correct |
18 |
Incorrect |
28 ms |
8192 KB |
Output isn't correct |
19 |
Incorrect |
27 ms |
8192 KB |
Output isn't correct |
20 |
Incorrect |
28 ms |
8192 KB |
Output isn't correct |