Submission #98105

#TimeUsernameProblemLanguageResultExecution timeMemory
98105dalgerokAutomobil (COCI17_automobil)C++17
100 / 100
23 ms8192 KiB
#include<bits/stdc++.h> using namespace std; const int N = 1e6 + 5, MOD = 1e9 + 7; int n, m, k, a[N], b[N], ans; int main(){ ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0); cin >> n >> m >> k; for(int i = 1; i <= n; i++){ b[i] = 1; } for(int i = 1; i <= m; i++){ a[i] = 1; } while(k--){ char c; int x, y; cin >> c >> x >> y; if(c == 'R'){ b[x] = 1LL * b[x] * y % MOD; } else{ a[x] = 1LL * a[x] * y % MOD; } } int cur1 = 0, cur2 = 0; for(int i = 1; i <= m; i++){ cur1 = (cur1 + 1LL * i * a[i]) % MOD; cur2 = (cur2 + 1LL * m * a[i]) % MOD; } for(int i = 1; i <= n; i++){ ans = (ans + 1LL * b[i] * (cur1 + 1LL * cur2 * (i - 1) % MOD) % MOD) % MOD; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...