# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
278845 | shrek12357 | Automobil (COCI17_automobil) | C++14 | 28 ms | 16032 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 <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <climits>
#include <cmath>
#include <fstream>
#include <queue>
using namespace std;
#define MOD 1000000007
#define MAXN 1000005
long long add(long long a, long long b){
return (a+b)%MOD;
}
long long mult(long long a, long long b){
return (a*b)%MOD;
}
int main() {
long long n, m, k;
cin >> n >> m >> k;
long long rows[MAXN], cols[MAXN];
for (int i = 0; i < MAXN; i++) {
rows[i] = 1;
cols[i] = 1;
}
for (int i = 0; i < k; i++) {
char c;
long long a, b;
cin >> c >> a >> b;
if (c == 'R') {
rows[a] = mult(rows[a], b);
}
else {
cols[a] = mult(cols[a], b);
}
}
long long num1 = 0, num2 = 0;
for (int i = 1; i <= m; i++) {
num1 = add(num1, cols[i]);
num2 = add(num2, mult(i, cols[i]));
}
long long ans = 0;
for (int i = 1; i <= n; i++) {
long long cur = add(num2, mult(m, mult(i - 1, num1)));
ans = add(ans, mult(rows[i], cur));
}
cout << ans << endl;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |