Submission #81268

# Submission time Handle Problem Language Result Execution time Memory
81268 2018-10-24T09:41:11 Z ngot23 Automobil (COCI17_automobil) C++11
100 / 100
34 ms 16228 KB
#include<bits/stdc++.h>
#define rep(i, a, b) for(long long i=(a) ; i<=(b) ; ++i)
#define Task ""
using namespace std;
const int N=1000005;
const int mod=1000000007;
long long col[N], row[N], m, n, k;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    //freopen(Task".inp", "r", stdin);
    //freopen(Task".out", "w", stdout);
    cin >> m >> n >> k;
    rep(i, 1, m) row[i]=1;
    rep(i, 1, n) col[i]=1;
    rep(i, 1, k) {
        char c;
        long long x, y;
        cin >> c >> x >> y;
        if(c=='R') (row[x]*=y)%=mod;
        else (col[x]*=y)%=mod;

    }
    long long val1=0, val2=0;
    rep(i, 1, n) {
        val1=(val1+1ll*col[i]*i)%mod;
        val2=(val2+1ll*col[i]*n)%mod;
    }
    long long ans=0;
    rep(i, 1, m) {
        long long xx=(1ll*(i-1)*val2)%mod;
        ans=(((0ll+val1+xx) % mod)*row[i]+ans)%mod;
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB Output is correct
2 Correct 2 ms 500 KB Output is correct
3 Correct 2 ms 500 KB Output is correct
4 Correct 2 ms 516 KB Output is correct
5 Correct 2 ms 564 KB Output is correct
6 Correct 2 ms 580 KB Output is correct
7 Correct 2 ms 580 KB Output is correct
8 Correct 2 ms 592 KB Output is correct
9 Correct 3 ms 592 KB Output is correct
10 Correct 3 ms 720 KB Output is correct
11 Correct 6 ms 3040 KB Output is correct
12 Correct 16 ms 8928 KB Output is correct
13 Correct 3 ms 8928 KB Output is correct
14 Correct 17 ms 10336 KB Output is correct
15 Correct 17 ms 10336 KB Output is correct
16 Correct 27 ms 16224 KB Output is correct
17 Correct 27 ms 16224 KB Output is correct
18 Correct 26 ms 16224 KB Output is correct
19 Correct 34 ms 16228 KB Output is correct
20 Correct 27 ms 16228 KB Output is correct