Submission #314468

# Submission time Handle Problem Language Result Execution time Memory
314468 2020-10-20T02:22:22 Z FlashGamezzz Automobil (COCI17_automobil) C++17
100 / 100
35 ms 16000 KB
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>

using namespace std;

int n, m, k, mod = 1000000007;
long rp[1000000], cp[1000000], cs = 0, sum = 0, ans = 0;

int main() {
	ios_base::sync_with_stdio(false);
	cin >> n >> m >> k;
	for (int i = 0; i < n; i++){
		rp[i] = 1;
	}
	for (int i = 0; i < m; i++){
		cp[i] = 1;
	}
	for (int i = 0; i < k; i++){
		string r; cin >> r;
		int x, y; cin >> x >> y;
		if (r.compare("R") == 0){
			rp[x-1] *= y; rp[x-1] %= mod;
		} else {
			cp[x-1] *= y; cp[x-1] %= mod;
		}
	}
	for (int i = 0; i < m; i++){
		cs += cp[i]; cs %= mod;
		sum += (i+1)*cp[i]; sum %= mod;
	}
	for (int i = 0; i < n; i++){
		ans += sum*rp[i]; ans %= mod;
		sum += cs*m; sum %= mod;
	}
	cout << ans << endl;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 384 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 1 ms 384 KB Output is correct
5 Correct 1 ms 384 KB Output is correct
6 Correct 1 ms 384 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 6 ms 2816 KB Output is correct
12 Correct 19 ms 8704 KB Output is correct
13 Correct 2 ms 896 KB Output is correct
14 Correct 21 ms 10112 KB Output is correct
15 Correct 19 ms 9088 KB Output is correct
16 Correct 34 ms 16000 KB Output is correct
17 Correct 35 ms 16000 KB Output is correct
18 Correct 34 ms 16000 KB Output is correct
19 Correct 34 ms 16000 KB Output is correct
20 Correct 35 ms 16000 KB Output is correct