# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
470910 | mariowong | Automobil (COCI17_automobil) | C++14 | 21 ms | 23756 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 <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;
#define x first
#define y second
const long long MOD = 1000000007;
const long long I2 = 500000004;
long long ans, top[1000055], d[1000055], rows[1000055];
int n, m, k;
int main () {
scanf("%d%d%d", &n, &m, &k);
for (int i = 1; i <= m; i++) {
top[i] = i;
d[i] = m;
}
for (int i = 1; i <= n; i++)
rows[i] = 1;
while (k--) {
char typ;
int x, y;
scanf("\n%c%d%d", &typ, &x, &y);
if (typ == 'R') {
rows[x] = rows[x] * y % MOD;
} else
if (typ == 'S') {
top[x] = top[x] * y % MOD;
d[x] = d[x] * y % MOD;
}
}
long long topsum = 0, dsum = 0;
for (int i = 1; i <= m; i++) {
topsum += top[i];
dsum += d[i];
}
topsum %= MOD;
dsum %= MOD;
for (int i = 1; i <= n; i++)
ans += rows[i] * ((long long)(i - 1) * dsum % MOD + topsum) % MOD;
printf("%lld\n", ans % MOD);
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |