Submission #971974

# Submission time Handle Problem Language Result Execution time Memory
971974 2024-04-29T15:57:33 Z vjudge1 Automobil (COCI17_automobil) C++17
100 / 100
14 ms 16216 KB
#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 time Memory Grader output
1 Correct 1 ms 2396 KB Output is correct
2 Correct 1 ms 2396 KB Output is correct
3 Correct 1 ms 2548 KB Output is correct
4 Correct 2 ms 2392 KB Output is correct
5 Correct 2 ms 2396 KB Output is correct
6 Correct 1 ms 2396 KB Output is correct
7 Correct 1 ms 2396 KB Output is correct
8 Correct 2 ms 2396 KB Output is correct
9 Correct 1 ms 2396 KB Output is correct
10 Correct 1 ms 2396 KB Output is correct
11 Correct 6 ms 6748 KB Output is correct
12 Correct 7 ms 12888 KB Output is correct
13 Correct 2 ms 4700 KB Output is correct
14 Correct 7 ms 12892 KB Output is correct
15 Correct 8 ms 12892 KB Output is correct
16 Correct 14 ms 16108 KB Output is correct
17 Correct 12 ms 15960 KB Output is correct
18 Correct 12 ms 16216 KB Output is correct
19 Correct 13 ms 15964 KB Output is correct
20 Correct 12 ms 15960 KB Output is correct