답안 #236730

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
236730 2020-06-03T07:05:12 Z VEGAnn Automobil (COCI17_automobil) C++14
50 / 100
7 ms 512 KB
#include <bits/stdc++.h>
#define sz(x) ((int)x.size())
#define ft first
#define sd second
using namespace std;
const int N = 1010;
const int oo = int(2e9);
const int md = int(1e9) + 7;
unordered_map<int, int> row;
int n, m, k, col[N], inv2 = 500000004, ans = 0;

int mult(int x, int y) { return (1ll * x * y) % md;}
void MULT(int &x, int y) { x = mult(x, y); }

int sum(int x, int y){
    x += y;
    if (x >= md)
        x -= md;
    return x;
}

int sub(int x, int y){
    x -= y;
    if (x < 0)
        x += md;
    return x;
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);

#ifdef _LOCAL
    freopen("in.txt","r",stdin);
#endif // _LOCAL

    cin >> n >> m >> k;

    fill(col + 1, col + m + 1, 1);

    for (; k; k--){
        char c; int x, y;
        cin >> c >> x >> y;

        if (c == 'R'){
            if (row.find(x) == row.end())
                row[x] = 1;

            MULT(row[x], y);
        } else {
            MULT(col[x], y);
        }

    }

    for (int j = 1; j <= m; j++){
        if (col[j] == 0) continue;

        int sm = mult(mult(sum(j + j, mult(n - 1, m)), n), inv2);

        if (sz(row) > 0) {
            for (auto cr : row){
                int x = cr.ft, cf = cr.sd;

                sm = sub(sm, mult(x - 1, m));
                sm = sub(sm, j);

                int real_val = sum(mult(x - 1, m), j);
                MULT(real_val, cf);

                sm = sum(sm, real_val);
            }
        }

        ans = sum(ans, mult(sm, col[j]));
    }

    cout << ans << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 6 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 6 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 6 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 6 ms 384 KB Output is correct
10 Correct 7 ms 384 KB Output is correct
11 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
12 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
13 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
14 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
15 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
16 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
17 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
18 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
19 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)
20 Runtime error 5 ms 512 KB Execution killed with signal 11 (could be triggered by violating memory limits)