Submission #1097060

# Submission time Handle Problem Language Result Execution time Memory
1097060 2024-10-06T02:40:34 Z vjudge1 Automobil (COCI17_automobil) C++17
0 / 100
1000 ms 8296 KB
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0, _n = (n); i < _n; ++i)
#define FOR(i, a, b) for (int i = (a), _b = (b); i <= _b; ++i)
#define PR(a,n) { cerr << #a << " = "; FOR(_,1,n) cerr << a[_] << ' '; cerr << endl; }
#define PR0(a,n) { cerr << #a << " = "; REP(_,n) cerr << a[_] << ' '; cerr << endl; }
#define debug(x) cerr << #x << " = " << x << endl
#define TIME (1.0 * clock() / CLOCKS_PER_SEC)
#define __builtin_popcount __builtin_popcountll
typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
template <class T, class T2> ostream &operator<<(ostream &o, pair<T, T2> p)
{
    o << "(" << p.first << ", " << p.second << ")"; 
    return o;
}
namespace ModInt
{
    const int MOD = 1e9 + 7;
    int add(int x, int y)
    {
        return (x + y) % MOD;
    }
    int sub(int x, int y)
    {
        return (x - y + MOD) % MOD;
    }
    int mul(int x, int y)
    {
        return 1ll * x * y % MOD;
    }
    int pow_mod(int x, int y)
    {
        if (y == 0)
            return 1;
        int t = pow_mod(x, y >> 1);
        if (y % 2 == 0)
            return mul(t, t);
        return mul(x, mul(t, t));
    }
    int div(int x, int y)
    {
        return mul(x, pow_mod(y, MOD - 2));
    }
    int sum_progress(int fi, int len, int d)
    {
        int last = fi + (len - 1) * d;
        return div(mul(add(fi, last), len), 2);  
    }
}

using namespace ModInt;
signed main()
{
    #ifdef LOCAL
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector <int> hRow(n + 1, 1), hCol(m + 1, 1);
    while (q--)
    {
        char type;
        int pos, val;
        cin >> type >> pos >> val;
        if (type == 'R')
            hRow[pos] = mul(hRow[pos], val);
        else
            hCol[pos] = mul(hCol[pos], val);
    }
    vector <int> rowGreaterThan1;
    int res = 0;
    for (int i = 1 ; i <= n; ++i)
    {
        if (hRow[i] != 1)
        {
            rowGreaterThan1.push_back(i);
            for (int j = 1; j <= m; ++j)
                res = add(res, mul(hRow[i], mul(hCol[j], (i - 1) * m + 1)));
        }
    }
    for (int j = 1; j <= m; ++j)
    {
        res = mul(hCol[j], add(res, sum_progress(j, n, m)));
        for (auto i: rowGreaterThan1)
            res = sub(res, mul(hCol[j], (i - 1) * m + 1));
    }
    cout << res;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 352 KB Output isn't correct
2 Incorrect 2 ms 344 KB Output isn't correct
3 Incorrect 0 ms 348 KB Output isn't correct
4 Incorrect 1 ms 348 KB Output isn't correct
5 Incorrect 1 ms 348 KB Output isn't correct
6 Incorrect 1 ms 348 KB Output isn't correct
7 Incorrect 2 ms 348 KB Output isn't correct
8 Incorrect 1 ms 348 KB Output isn't correct
9 Incorrect 2 ms 472 KB Output isn't correct
10 Incorrect 3 ms 348 KB Output isn't correct
11 Incorrect 319 ms 1628 KB Output isn't correct
12 Execution timed out 1053 ms 4444 KB Time limit exceeded
13 Incorrect 114 ms 600 KB Output isn't correct
14 Incorrect 207 ms 5212 KB Output isn't correct
15 Execution timed out 1056 ms 4700 KB Time limit exceeded
16 Execution timed out 1045 ms 8284 KB Time limit exceeded
17 Execution timed out 1033 ms 8280 KB Time limit exceeded
18 Execution timed out 1067 ms 8284 KB Time limit exceeded
19 Execution timed out 1035 ms 8296 KB Time limit exceeded
20 Execution timed out 1012 ms 8280 KB Time limit exceeded