Submission #199947

# Submission time Handle Problem Language Result Execution time Memory
199947 2020-02-04T10:29:54 Z Osama_Alkhodairy Automobil (COCI17_automobil) C++17
100 / 100
36 ms 8184 KB
#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 time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 376 KB Output is correct
4 Correct 5 ms 376 KB Output is correct
5 Correct 5 ms 376 KB Output is correct
6 Correct 5 ms 376 KB Output is correct
7 Correct 5 ms 376 KB Output is correct
8 Correct 6 ms 376 KB Output is correct
9 Correct 5 ms 376 KB Output is correct
10 Correct 5 ms 376 KB Output is correct
11 Correct 10 ms 1784 KB Output is correct
12 Correct 22 ms 5628 KB Output is correct
13 Correct 6 ms 760 KB Output is correct
14 Correct 25 ms 7032 KB Output is correct
15 Correct 23 ms 5112 KB Output is correct
16 Correct 36 ms 8184 KB Output is correct
17 Correct 35 ms 8184 KB Output is correct
18 Correct 36 ms 8184 KB Output is correct
19 Correct 35 ms 8184 KB Output is correct
20 Correct 36 ms 8184 KB Output is correct