Submission #1118359

# Submission time Handle Problem Language Result Execution time Memory
1118359 2024-11-25T11:46:37 Z happyTororo1 Automobil (COCI17_automobil) C++17
100 / 100
22 ms 16148 KB
#include <bits/stdc++.h>
#define N 1000005
#define int long long
using namespace std;
const int mod = 1e9 + 7;
int n, m, dr[N], dc[N], q, ans, x, sum, tmp, base;
char c;
int32_t main() {
	ios::sync_with_stdio(false), cin.tie(0);
	cin >> n >> m >> q;
	for (int i = 0; i <= max(n, m); ++i) dr[i] = dc[i] = 1;
	while (q--) {
		cin >> c >> x >> tmp;
		if (c == 'S') dc[x] = (dc[x] * tmp) % mod;
		else dr[x - 1] = (dr[x - 1] * tmp) % mod;
	}
	for (int i = 0; i < n; ++i) {
		sum = (sum + dr[i]) % mod;
		base = (base + (((i * m) % mod) * dr[i]) % mod) % mod;
	}
	sum %= mod;
	base %= mod;
	for (int i = 1; i <= m; ++i) ans = (ans + (((base + (i * sum) % mod) * dc[i]) % mod)) % mod;
	cout << ans % mod << "\n";
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 352 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 348 KB Output is correct
5 Correct 1 ms 348 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 ms 348 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 5 ms 3164 KB Output is correct
12 Correct 13 ms 11208 KB Output is correct
13 Correct 2 ms 1120 KB Output is correct
14 Correct 15 ms 13660 KB Output is correct
15 Correct 13 ms 9820 KB Output is correct
16 Correct 21 ms 15980 KB Output is correct
17 Correct 22 ms 15964 KB Output is correct
18 Correct 20 ms 15964 KB Output is correct
19 Correct 21 ms 16148 KB Output is correct
20 Correct 20 ms 15964 KB Output is correct