Submission #894648

# Submission time Handle Problem Language Result Execution time Memory
894648 2023-12-28T15:21:50 Z reginox Automobil (COCI17_automobil) C++17
100 / 100
11 ms 16120 KB
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll maxn = 1e6+3, mod = 1e9+7;
ll r[maxn], c[maxn], res, n, m, k, sumc, sum;
void sub1(){
	for(ll i = 1; i <= n; i++){
		for(ll j = 1; j <= m; j++){
			res += ((i-1)*m+j)*(r[i]*c[j])%mod;
			res%=mod;
		}
	}
	cout << res;
}

void sub2(){
	for(ll i = 1; i <= m; i++){
		sum += c[i]*i;
		sumc += c[i];
		sum %= mod;
	}
	sumc = (sumc * m) % mod;
	for(ll i = 1; i <= n; i++){
		res += (sum*r[i])%mod;
		res%=mod;
		sum += sumc;
		sum %= mod;
	}
	cout << res;
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	for(ll i = 1; i <= n; i++) r[i]=1;
	for(ll i = 1; i <= m; i++) c[i]=1;
	char t;
	ll x, y;
	while(k--){
		cin >> t >> x >> y;
		if(t=='R') r[x] = (r[x]*y)%mod;
		else c[x] = (c[x]*y)%mod;
	}
sub2();
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2392 KB Output is correct
2 Correct 1 ms 2392 KB Output is correct
3 Correct 1 ms 2396 KB Output is correct
4 Correct 1 ms 2396 KB Output is correct
5 Correct 1 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 1 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 8 ms 12888 KB Output is correct
13 Correct 1 ms 4700 KB Output is correct
14 Correct 7 ms 12948 KB Output is correct
15 Correct 7 ms 12892 KB Output is correct
16 Correct 11 ms 15964 KB Output is correct
17 Correct 11 ms 16116 KB Output is correct
18 Correct 11 ms 15964 KB Output is correct
19 Correct 11 ms 15964 KB Output is correct
20 Correct 11 ms 16120 KB Output is correct