Submission #236743

# Submission time Handle Problem Language Result Execution time Memory
236743 2020-06-03T07:41:14 Z NONAME Automobil (COCI17_automobil) C++17
50 / 100
9 ms 512 KB
#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 *= y) %= base; }
void sum(ll &x, ll y) { (x += 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; ll x, y;
		
		cin >> type >> x >> y;
		
		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 time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 8 ms 384 KB Output is correct
3 Correct 6 ms 384 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
5 Correct 8 ms 384 KB Output is correct
6 Correct 6 ms 384 KB Output is correct
7 Correct 9 ms 384 KB Output is correct
8 Correct 7 ms 384 KB Output is correct
9 Correct 8 ms 384 KB Output is correct
10 Correct 8 ms 384 KB Output is correct
11 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 5 ms 384 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)