Submission #98105

# Submission time Handle Problem Language Result Execution time Memory
98105 2019-02-20T17:24:31 Z dalgerok Automobil (COCI17_automobil) C++17
100 / 100
23 ms 8192 KB
#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 time Memory Grader output
1 Correct 2 ms 512 KB Output is correct
2 Correct 2 ms 384 KB Output is correct
3 Correct 2 ms 384 KB Output is correct
4 Correct 3 ms 384 KB Output is correct
5 Correct 2 ms 384 KB Output is correct
6 Correct 2 ms 384 KB Output is correct
7 Correct 2 ms 384 KB Output is correct
8 Correct 2 ms 384 KB Output is correct
9 Correct 2 ms 384 KB Output is correct
10 Correct 2 ms 384 KB Output is correct
11 Correct 5 ms 1720 KB Output is correct
12 Correct 12 ms 4608 KB Output is correct
13 Correct 3 ms 768 KB Output is correct
14 Correct 13 ms 5248 KB Output is correct
15 Correct 11 ms 4736 KB Output is correct
16 Correct 23 ms 8192 KB Output is correct
17 Correct 22 ms 8192 KB Output is correct
18 Correct 20 ms 8192 KB Output is correct
19 Correct 20 ms 8192 KB Output is correct
20 Correct 20 ms 8192 KB Output is correct