# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1273430 | chanhchuong123 | Automobil (COCI17_automobil) | C++20 | 1097 ms | 12096 KiB |
#include<bits/stdc++.h>
using namespace std;
const bool multiTest = false;
#define task "C"
#define fi first
#define se second
#define MASK(i) (1LL << (i))
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define BIT(mask, i) ((mask) >> (i) & 1)
template<typename T1, typename T2> bool minimize(T1 &a, T2 b) {
if (a > b) a = b; else return 0; return 1;
}
template<typename T1, typename T2> bool maximize(T1 &a, T2 b) {
if (a < b) a = b; else return 0; return 1;
}
const int MOD = 1e9 + 7;
const int MAX = 1000100;
int n, m, k;
int row[MAX];
int col[MAX];
int sumCol[MAX];
void process(void) {
cin >> n >> m >> k;
for (int i = 1; i <= n; ++i) {
row[i] = 1;
}
for (int j = 1; j <= m; ++j) {
col[j] = 1;
sumCol[j] = (1LL * j * n % MOD + (n - 1LL) * n / 2 % MOD * m) % MOD;
}
while (k--) {
char type; int X, Y;
cin >> type >> X >> Y;
if (type == 'R') {
for (int j = 1; j <= m; ++j) {
sumCol[j] -= ((X - 1LL) * m + j) % MOD * row[X] % MOD;
if (sumCol[j] < 0) sumCol[j] += MOD;
}
row[X] = 1LL * row[X] * Y % MOD;
for (int j = 1; j <= m; ++j) {
sumCol[j] = (sumCol[j] + ((X - 1LL) * m + j) % MOD * row[X] % MOD) % MOD;
}
} else {
col[X] = 1LL * col[X] * Y % MOD;
}
}
int ans = 0;
for (int j = 1; j <= m; ++j) {
ans = 1LL * (ans + 1LL * sumCol[j] * col[j] % MOD) % MOD;
}
cout << ans;
}
int main(void) {
ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int nTest = 1; if (multiTest) cin >> nTest;
while (nTest--) {
process();
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |