#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;
#define MOD 1000000007
#define MAXN 1000005
long long add(long long a, long long b){
return (a+b)%MOD;
}
long long mult(long long a, long long b){
return (a*b)%MOD;
}
int main() {
long long n, m, k;
cin >> n >> m >> k;
long long rows[MAXN], cols[MAXN];
for (int i = 0; i < MAXN; i++) {
rows[i] = 1;
cols[i] = 1;
}
for (int i = 0; i < k; i++) {
char c;
long long a, b;
cin >> c >> a >> b;
if (c == 'R') {
rows[a] = mult(rows[a], b);
}
else {
cols[a] = mult(cols[a], b);
}
}
long long num1 = 0, num2 = 0;
for (int i = 1; i <= m; i++) {
num1 = add(num1, cols[i]);
num2 = add(num2, mult(i, cols[i]));
}
long long ans = 0;
for (int i = 1; i <= n; i++) {
long long cur = add(num2, mult(m, mult(i - 1, num1)));
ans = add(ans, mult(rows[i], cur));
}
cout << ans << endl;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
10 ms |
16000 KB |
Output is correct |
2 |
Correct |
10 ms |
16000 KB |
Output is correct |
3 |
Correct |
11 ms |
16000 KB |
Output is correct |
4 |
Correct |
11 ms |
16000 KB |
Output is correct |
5 |
Correct |
10 ms |
16000 KB |
Output is correct |
6 |
Correct |
10 ms |
16000 KB |
Output is correct |
7 |
Correct |
11 ms |
16000 KB |
Output is correct |
8 |
Correct |
10 ms |
16000 KB |
Output is correct |
9 |
Correct |
10 ms |
16032 KB |
Output is correct |
10 |
Correct |
11 ms |
16008 KB |
Output is correct |
11 |
Correct |
13 ms |
16000 KB |
Output is correct |
12 |
Correct |
21 ms |
16000 KB |
Output is correct |
13 |
Correct |
12 ms |
16000 KB |
Output is correct |
14 |
Correct |
21 ms |
16000 KB |
Output is correct |
15 |
Correct |
20 ms |
16000 KB |
Output is correct |
16 |
Correct |
28 ms |
16000 KB |
Output is correct |
17 |
Correct |
28 ms |
16000 KB |
Output is correct |
18 |
Correct |
28 ms |
16000 KB |
Output is correct |
19 |
Correct |
28 ms |
16000 KB |
Output is correct |
20 |
Correct |
28 ms |
16000 KB |
Output is correct |