Submission #236741

#TimeUsernameProblemLanguageResultExecution timeMemory
236741NONAMEAutomobil (COCI17_automobil)C++17
0 / 100
8 ms512 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
const ll base = 1e9 + 7;

ll row[1010], col[1010];

void mul(ll &x, ll y) { (x *= 1ll * y) %= base; }
void sum(ll &x, ll y) { (x += 1ll * y) %= base; }

int main() {
	ll n, m, q;
	
	cin >> n >> m >> q;
	
	for (int i = 1; i <= n; ++i)
		row[i] = 1;
		
	for (int j = 1; j <= m; ++j)
		col[j] = 1;
	
	while (q--) {
		char type; int x, y;
		
		cin >> type >> x >> y;
		--x;
		
		if (type == 'R') mul(row[x], y);
			else mul(col[x], y);
	}
	
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
	for (int j = 1; j <= m; ++j) {
		ll rw = row[i], cl = col[j];
		ll vl = (i - 1) * m + j;
		
		mul(rw, cl);
		mul(vl, rw);
		
		sum(ans, vl);
	}
	
	cout << ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...