# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
198593 | 2020-01-26T18:16:51 Z | ZwariowanyMarcin | Automobil (COCI17_automobil) | C++14 | 21 ms | 8188 KB |
#include <bits/stdc++.h> #define fi first #define se second #define mp make_pair #define ss(x) (int) x.size() #define pb push_back #define LL long long #define ld long double #define cat(x) cerr << #x << " = " << x << endl #define FOR(i, j, n) for(int i = j; i <= n; ++i) #define boost cin.tie(0), ios_base::sync_with_stdio(0); using namespace std; const int MOD = 1e9 + 7; const int nax = 1e6 + 111; int n, m, k; char c; int x, y; int row[nax]; int col[nax]; int main() { scanf ("%d %d %d", &n, &m, &k); for (int i = 1; i <= max(n, m); ++i) row[i] = col[i] = 1; for (int i = 1; i <= k; ++i) { scanf (" %c%d%d", &c, &x, &y); if (c == 'R') row[x] = 1LL * row[x] * y % MOD; else col[x] = 1LL * col[x] * y % MOD; } LL ans = 0; LL value = 0; LL sum = 0; for (int i = 1; i <= n; ++i) { sum = (sum + row[i]) % MOD; value = (value + 1LL * (1 + 1LL * (i - 1) * m) % MOD * row[i]) % MOD; } for (int i = 1; i <= m; ++i) { ans = (ans + value * col[i]) % MOD; value = (value + sum) % MOD; } printf ("%lld", ans); return 0; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 6 ms | 504 KB | Output is correct |
2 | Correct | 5 ms | 376 KB | Output is correct |
3 | Correct | 6 ms | 376 KB | Output is correct |
4 | Correct | 6 ms | 376 KB | Output is correct |
5 | Correct | 5 ms | 376 KB | Output is correct |
6 | Correct | 6 ms | 376 KB | Output is correct |
7 | Correct | 5 ms | 376 KB | Output is correct |
8 | Correct | 5 ms | 376 KB | Output is correct |
9 | Correct | 5 ms | 376 KB | Output is correct |
10 | Correct | 5 ms | 376 KB | Output is correct |
11 | Correct | 8 ms | 1784 KB | Output is correct |
12 | Correct | 14 ms | 5496 KB | Output is correct |
13 | Correct | 6 ms | 760 KB | Output is correct |
14 | Correct | 16 ms | 7032 KB | Output is correct |
15 | Correct | 17 ms | 5112 KB | Output is correct |
16 | Correct | 21 ms | 8188 KB | Output is correct |
17 | Correct | 21 ms | 8184 KB | Output is correct |
18 | Correct | 21 ms | 8184 KB | Output is correct |
19 | Correct | 20 ms | 8184 KB | Output is correct |
20 | Correct | 21 ms | 8184 KB | Output is correct |