#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
const ll mod = 1e9+7;
void solve(){
int n,m,q;
cin>>n>>m>>q;
vector <vector<ll>> v(n,vector<ll>(m));
for(int i=0;i<n;i++){
for(int j=0;j<m;j++){
v[i][j] = i*m+j+1;
}
}
while(q--){
char c;
int x,y;
cin>>c>>x>>y;
x --;
if(c == 'R'){
for(int i=0;i<m;i++){
v[x][i] *= y;
v[x][i] %= mod;
}
}
else {
for(int i=0;i<n;i++){
v[i][x] *= y;
v[i][x] %= mod;
}
}
}
ll ans = 0;
for(auto i : v){
for(auto j : i){
ans += j;
ans %= mod;
}
}
cout<<ans<<endl;
}
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int t=1;
// cin>>t;
while(t--){
solve();
}
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
716 KB |
Output is correct |
2 |
Correct |
5 ms |
2936 KB |
Output is correct |
3 |
Correct |
1 ms |
844 KB |
Output is correct |
4 |
Correct |
1 ms |
568 KB |
Output is correct |
5 |
Correct |
6 ms |
3632 KB |
Output is correct |
6 |
Correct |
3 ms |
1868 KB |
Output is correct |
7 |
Correct |
7 ms |
3784 KB |
Output is correct |
8 |
Correct |
3 ms |
1740 KB |
Output is correct |
9 |
Correct |
5 ms |
2892 KB |
Output is correct |
10 |
Correct |
6 ms |
3788 KB |
Output is correct |
11 |
Runtime error |
34 ms |
65540 KB |
Execution killed with signal 9 |
12 |
Runtime error |
33 ms |
65540 KB |
Execution killed with signal 9 |
13 |
Runtime error |
35 ms |
65540 KB |
Execution killed with signal 9 |
14 |
Runtime error |
34 ms |
65540 KB |
Execution killed with signal 9 |
15 |
Runtime error |
37 ms |
65540 KB |
Execution killed with signal 9 |
16 |
Runtime error |
37 ms |
65540 KB |
Execution killed with signal 9 |
17 |
Runtime error |
35 ms |
65540 KB |
Execution killed with signal 9 |
18 |
Runtime error |
37 ms |
65540 KB |
Execution killed with signal 9 |
19 |
Runtime error |
38 ms |
65540 KB |
Execution killed with signal 9 |
20 |
Runtime error |
37 ms |
65540 KB |
Execution killed with signal 9 |