| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 631618 | Justin1 | Automobil (COCI17_automobil) | C++14 | 125 ms | 31692 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 int __int128
using namespace std;
long long n,m,k,x,y,z;
int c[1000005], r[1000005];
char ch;
vector<int> colupd;
int mod(int x) {
	const int modval = 1e9+7;
	return ((x % modval) + modval) % modval;
}
signed main() {
	cin.tie(0), cout.tie(0) -> sync_with_stdio(0);
	cin >> n >> m >> k;
	for (int i = 1; i <= n; i++) r[i] = 1;
	for (int i = 1; i <= m; i++) c[i] = 1;
	for (int i = 1; i <= k; i++) {
		cin >> ch >> x >> y;
		if (ch == 'R') r[x] = mod(r[x] * y);
		else c[x] = mod(c[x] * y);
	}
	long long ans = mod((1 + n*m) * (n*m) / 2);
	for (int i = 1; i <= m; i++) {
		if (c[i] != 1) colupd.push_back(i);
		ans += mod(mod(n*(2*i+(n-1)*m)/2) * mod(c[i]-1));
		ans = mod(ans);
	}
	for (int i = 1; i <= n; i++) {
		int st = m*(i-1)+1;
		ans += mod(mod(m*(2*st+m-1)/2) * mod(r[i]-1));
		if (r[i] != 1) {
			for (auto j : colupd) {
				int val = mod(m*(i-1) + j);
				ans -= mod(val * mod(r[i] + c[j] - 2));
				ans += mod(val * mod(r[i] * c[j] - 1));
			}
		}
		ans = mod(ans);
	}
	cout << ans << "\n";
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
