Submission #894645

# Submission time Handle Problem Language Result Execution time Memory
894645 2023-12-28T15:20:43 Z reginox Automobil (COCI17_automobil) C++17
50 / 100
12 ms 16136 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;
	}
	if(n <= 1000 && m <= 1000){
		sub1();
	}
	else{
		sub2();
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 2396 KB Output isn't correct
2 Incorrect 2 ms 2396 KB Output isn't correct
3 Incorrect 1 ms 2396 KB Output isn't correct
4 Incorrect 1 ms 2396 KB Output isn't correct
5 Incorrect 2 ms 2396 KB Output isn't correct
6 Incorrect 1 ms 2396 KB Output isn't correct
7 Incorrect 2 ms 2396 KB Output isn't correct
8 Incorrect 1 ms 2396 KB Output isn't correct
9 Incorrect 2 ms 2516 KB Output isn't correct
10 Incorrect 2 ms 2536 KB Output isn't correct
11 Correct 2 ms 6748 KB Output is correct
12 Correct 7 ms 12892 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 15964 KB Output is correct
18 Correct 11 ms 16132 KB Output is correct
19 Correct 12 ms 16136 KB Output is correct
20 Correct 12 ms 16132 KB Output is correct