Submission #971922

#TimeUsernameProblemLanguageResultExecution timeMemory
971922vjudge1Automobil (COCI17_automobil)C++17
50 / 100
1091 ms15964 KiB
#include <bits/stdc++.h>
#pragma GCC optimize ("03")
using namespace std;
using ll = long long;
#define MOD 1000000007
ll n, m, k;
ll power(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1) {
            res = (res * a) % MOD;
        }
        a = (a * a) % MOD;
        b >>= 1;
    }
    return res;
}

int main() {
    cin >> n >> m >> k;
    vector<ll> row(n + 1, 1), col(m + 1, 1);
    while (k--) {
        char type;
        ll x, y;
        cin >> type >> x >> y;
        if (type == 'R') {
            row[x] = (row[x] * y) % MOD;
        } else {
            col[x] = (col[x] * y) % MOD;
        }
    }

    ll sum = 0;
    for (ll i = 1; i <= n; i++) {
        for (ll j = 1; j <= m; j++) {
            sum = (sum + ((i*m + j - m) * row[i] % MOD * col[j] % MOD)) % MOD;
        }
    }

    cout << sum << "\n";
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...