| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 198593 | ZwariowanyMarcin | Automobil (COCI17_automobil) | C++14 | 21 ms | 8188 KiB | 
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define ss(x) (int) x.size()
#define pb push_back
#define LL long long
#define ld long double
#define cat(x) cerr << #x << " = " << x << endl
#define FOR(i, j, n) for(int i = j; i <= n; ++i)
#define boost cin.tie(0), ios_base::sync_with_stdio(0);
using namespace std;		
const int MOD = 1e9 + 7;
const int nax = 1e6 + 111;
int n, m, k;
char c;
int x, y;
int row[nax];
int col[nax];
int main() {
	scanf ("%d %d %d", &n, &m, &k);
	for (int i = 1; i <= max(n, m); ++i)
		row[i] = col[i] = 1;
	for (int i = 1; i <= k; ++i) {
		scanf (" %c%d%d", &c, &x, &y);
		if (c == 'R')
			row[x] = 1LL * row[x] * y % MOD;
		else
			col[x] = 1LL * col[x] * y % MOD;
	}
	
	LL ans = 0;
	LL value = 0;
	LL sum = 0;
	
	for (int i = 1; i <= n; ++i) {
		sum = (sum + row[i]) % MOD;
		value = (value + 1LL * (1 + 1LL * (i - 1) * m) % MOD * row[i]) % MOD;
	}
	
	for (int i = 1; i <= m; ++i) {
		ans = (ans + value * col[i]) % MOD;
		value = (value + sum) % MOD;
	}
	printf ("%lld", ans);	
	
	return 0;
}
Compilation message (stderr)
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
