Submission #199947

#TimeUsernameProblemLanguageResultExecution timeMemory
199947Osama_AlkhodairyAutomobil (COCI17_automobil)C++17
100 / 100
36 ms8184 KiB
#include <bits/stdc++.h>
using namespace std;
#define finish(x) return cout << x << endl, 0
#define ll long long

const int N = 1000001;

int n, m, k, row[N], col[N], mod = 1e9 + 7;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> n >> m >> k;
    for(int i = 1 ; i <= max(n, m) ; i++){
        row[i] = col[i] = 1;
    }
    for(int i = 0 ; i < k ; i++){
        char c;
        int x, y;
        cin >> c >> x >> y;
        if(c == 'R') row[x] = 1LL * row[x] * y % mod;
        else col[x] = 1LL * col[x] * y % mod;
    }
    int sc = 0;
    for(int j = 1 ; j <= m ; j++){
        sc = (sc + col[j]) % mod;
    }
    int ans = 0;
    int cur = 0;
    for(int j = 1 ; j <= m ; j++){
        cur = (cur + 1LL * col[j] * j) % mod;
    }
    for(int i = 1 ; i <= n ; i++){
        ans = (ans + 1LL * cur * row[i]) % mod;
        cur = (cur + 1LL * sc * m) % mod;
    }
    cout << ans << endl;
}
#Verdict Execution timeMemoryGrader output
Fetching results...