#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define MOD 1000000007
ll n, m, k;
ll power(ll a, ll b) {
ll res = 1;
while (b > 0) {
if (b & 1) {
res = (res * a) % MOD;
}
a = (a * a) % MOD;
b >>= 1;
}
return res;
}
int main() {
cin >> n >> m >> k;
vector<ll> row(n + 1, 1), col(m + 1, 1);
while (k--) {
char type;
ll x, y;
cin >> type >> x >> y;
if (type == 'R') {
row[x] = (row[x] * y) % MOD;
} else {
col[x] = (col[x] * y) % MOD;
}
}
ll sum = 0;
for (ll i = 1; i <= n; i++) {
for (ll j = 1; j <= m; j++) {
sum = (sum + ((i*m + j - m) * row[i] % MOD * col[j] % MOD)) % MOD;
}
}
cout << sum << "\n";
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Correct |
2 ms |
456 KB |
Output is correct |
3 |
Correct |
1 ms |
348 KB |
Output is correct |
4 |
Correct |
1 ms |
348 KB |
Output is correct |
5 |
Correct |
2 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
448 KB |
Output is correct |
7 |
Correct |
2 ms |
348 KB |
Output is correct |
8 |
Correct |
1 ms |
348 KB |
Output is correct |
9 |
Correct |
2 ms |
348 KB |
Output is correct |
10 |
Correct |
3 ms |
348 KB |
Output is correct |
11 |
Execution timed out |
1059 ms |
2652 KB |
Time limit exceeded |
12 |
Execution timed out |
1053 ms |
8796 KB |
Time limit exceeded |
13 |
Execution timed out |
1014 ms |
856 KB |
Time limit exceeded |
14 |
Execution timed out |
1045 ms |
10072 KB |
Time limit exceeded |
15 |
Execution timed out |
1062 ms |
9052 KB |
Time limit exceeded |
16 |
Execution timed out |
1056 ms |
15964 KB |
Time limit exceeded |
17 |
Execution timed out |
1035 ms |
15960 KB |
Time limit exceeded |
18 |
Execution timed out |
1012 ms |
15960 KB |
Time limit exceeded |
19 |
Execution timed out |
1033 ms |
15964 KB |
Time limit exceeded |
20 |
Execution timed out |
1029 ms |
15960 KB |
Time limit exceeded |