Submission #971974

#TimeUsernameProblemLanguageResultExecution timeMemory
971974vjudge1Automobil (COCI17_automobil)C++17
100 / 100
14 ms16216 KiB
#include <bits/stdc++.h> using namespace std; const int MOD = 1e9+7; const int maxn = 1e6+5; using ll = long long; ll r[maxn], c[maxn]; ll ans, n, m, k, sum, sum2; int main(){ cin >> n >> m >> k; for(int i = 1; i <= n; i++) r[i] = 1; for(int i = 1; i <= m; i++) c[i] = 1; char t; ll x, y; while(k--){ cin >> t >> x >> y; if(t == 'R') r[x] = (r[x] * y) % MOD; else c[x] = (c[x] * y) % MOD; } for(int i = 1; i <= m; i++){ sum += c[i] * i; sum2 += c[i]; sum %= MOD; } sum2 = (sum2 * m) % MOD; for(int i = 1; i <= n; i++){ ans += (sum * r[i]) % MOD; ans %= MOD; sum += sum2; sum %= MOD; } cout << ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...