# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
236788 | NONAME | Automobil (COCI17_automobil) | C++17 | 29 ms | 16000 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll base = 1e9 + 7;
const int N = 1e6 + 10;
ll row[N], col[N];
void mul(ll &x, ll y) { (x *= y) %= base; }
void sum(ll &x, ll y) { (x += y) %= base; }
int main() {
ll n, m, q;
cin >> n >> m >> q;
for (int i = 1; i <= n; ++i)
row[i] = 1;
for (int j = 1; j <= m; ++j)
col[j] = 1;
while (q--) {
char type; ll x, y;
cin >> type >> x >> y;
if (type == 'R') mul(row[x], y);
else mul(col[x], y);
}
ll sm = 0;
for (int i = 1; i <= m; ++i)
sum(sm, col[i]);
ll cr = 0;
for (int i = 1; i <= m; ++i) {
ll vl = col[i];
mul(vl, i);
sum(cr, vl);
}
ll ans = 0;
for (int i = 1; i <= n; ++i) {
ll vl = cr;
mul(vl, row[i]);
sum(ans, vl);
vl = sm;
mul(vl, m);
sum(cr, vl);
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |