QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#131111 | #5162. 种花 | Heltion | 100 ✓ | 67ms | 12196kb | C++20 | 1.3kb | 2023-07-26 12:29:22 | 2023-07-26 12:29:23 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = int64_t;
constexpr i64 mod = 998244353;
int main() {
cin.tie(nullptr)->sync_with_stdio(false);
int t, id;
cin >> t >> id;
for (int ti = 0; ti < t; ti += 1) {
int n, m, c, f;
cin >> n >> m >> c >> f;
vector<string> s(n);
for (auto &si : s) {
cin >> si;
}
vector r(n, vector<int>(m, 1)), d(n, vector<int>(m, 1));
for (int i = n - 1; i >= 0; i -= 1) {
for (int j = m - 1; j >= 0; j -= 1) {
if (s[i][j] == '1') {
r[i][j] = d[i][j] = 0;
} else {
if (j + 1 < m) {
r[i][j] += r[i][j + 1];
}
if (i + 1 < n) {
d[i][j] += d[i + 1][j];
}
}
}
}
i64 nc = 0, nf = 0;
for (int i = 0; i < m; i += 1) {
i64 s = 0;
for (int j = 0; j < n; j += 1) {
if (r[j][i]) {
if (j >= 2 and r[j - 2][i] and r[j - 1][i]) {
s = (s + r[j - 2][i] - 1) % mod;
}
nc = (nc + s * (r[j][i] - 1)) % mod;
nf = (nf + s * (r[j][i] - 1) * (d[j][i] - 1)) %
mod;
} else {
s = 0;
}
}
}
cout << nc * c << " " << nf * f << "\n";
}
}
这程序好像有点Bug,我给组数据试试?
详细
Test #1:
score: 1
Accepted
time: 14ms
memory: 11996kb
input:
1 1 998 1000 0 0 0000100000100001000000000000011100000000010100100010000001100000000100011010000000011010001000100010000010001000011110010000000000010100000000001000000010000000100001000000101000010010010000000010010010000010001000010000000010000100001001001111010000000000010000000000100001111010011...
output:
0 0
result:
ok single line: '0 0'
Test #2:
score: 2
Accepted
time: 1ms
memory: 3496kb
input:
3 2 3 2 1 1 00 00 00 3 2 1 1 00 01 00 3 2 1 1 00 00 01
output:
1 0 1 0 0 0
result:
ok 3 lines
Test #3:
score: 3
Accepted
time: 1ms
memory: 3584kb
input:
5 3 4 2 1 1 00 00 00 00 4 2 1 1 00 01 00 00 4 2 1 1 00 00 01 00 4 2 1 1 00 00 00 01 4 2 1 1 00 00 00 10
output:
3 1 2 1 2 0 1 1 1 0
result:
ok 5 lines
Test #4:
score: 4
Accepted
time: 0ms
memory: 3672kb
input:
5 4 997 2 1 1 10 00 00 00 00 00 00 00 00 00 00 10 00 00 10 00 00 00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 00 10 00 00 00 01 11 00 00 00 00 00 00 00 00 10 00 00 00 00 00 10 01 00 00 00 00 00 00 00 01 01 00 00 00 10 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 00 00 00 10 00 00 00 00 00 00 0...
output:
5301 38550 1309 4386 841 2387 181 228 56 78
result:
ok 5 lines
Test #5:
score: 4
Accepted
time: 45ms
memory: 12124kb
input:
5 5 999 998 1 1 00100100100100101100100100100100100100100100110100110100101100100100110100100100100101100100110100100100101100101100101100100100100100100100101100101100110100100100110100100100100100100110100101110100101110100100110100100100100101100100100100100100101100100100100100100100100100100100...
output:
1952124 17488577 546673 2174022 186900 431806 63889 95010 20937 20375
result:
ok 5 lines
Test #6:
score: 6
Accepted
time: 39ms
memory: 12100kb
input:
5 6 995 1000 1 1 0000000000100101000000000000000000001010000100000000000000000100100000000001000000000000000000100000000101000000000000000000000000000000000000000000000001000000000000000100100000001000000000010000000000000000000000000100000000100000001011000100000000110000000000000000000000000000000...
output:
14235129 0 1993965 0 454532 0 118724 0 31475 0
result:
ok 5 lines
Test #7:
score: 10
Accepted
time: 1ms
memory: 3460kb
input:
5 7 10 10 1 1 0000000000 0000000100 0000100000 0000000000 0000000000 0000000000 0000000001 0000000000 0010000001 0000000000 9 10 1 1 1000000000 0000100000 0000010100 0001000001 0000000000 1001000001 0111010011 0000000100 0100001000 9 10 1 1 1100000001 0101100010 0010010000 0111010110 1001000110 1110...
output:
5890 12768 437 540 9 12 39 20 5 0
result:
ok 5 lines
Test #8:
score: 6
Accepted
time: 1ms
memory: 3476kb
input:
5 8 20 18 1 1 010010000010000000 000000000010000110 000000101000000000 000000000000001000 000000000000000000 000000010000000000 010000000010100000 000100000100000001 000000000000001010 000000000100000000 000000100000000001 000001000000100000 000000000100001010 100000000000000000 000000000000000100 0...
output:
32999 126558 11013 37023 357 333 151 121 52 47
result:
ok 5 lines
Test #9:
score: 6
Accepted
time: 0ms
memory: 3480kb
input:
5 9 28 29 1 1 01000000000001000000000000100 00001000010000000000010000001 00000000000000000000000000001 00000100000000100001100100100 00001110100010100011000000000 00000000000000010000100010010 00001000000000000000000000000 00000000000000000010000000000 01000000000010000001001000010 0000100000001010...
output:
117502 565585 11489 25154 4162 8339 473 352 132 115
result:
ok 5 lines
Test #10:
score: 8
Accepted
time: 1ms
memory: 3556kb
input:
5 10 48 50 1 1 01001000001000001000000000001000010000000000000000 00000000000000100000100101000000000000000001000000 00001000000100000100000000110000000000000000000000 00000000000000000000000000000001000100000000001001 00100000000000000000000100010000000010000000000100 001000000000000100000000101000...
output:
847186 6581666 81195 259022 6965 10793 2308 3158 529 516
result:
ok 5 lines
Test #11:
score: 10
Accepted
time: 0ms
memory: 3584kb
input:
5 11 95 90 1 1 001100000100000011000000000000000100000000000001000000000000000100000010000000000000000000 000000000000000000000000000000100000000000000000000100000000000000000000100000000010000000 000000000100000000011000000010001000000000000000000001100000010000000000100001000010000000 000000000000...
output:
3308449 27745538 327127 1213705 44875 88885 10033 14745 1823 1423
result:
ok 5 lines
Test #12:
score: 6
Accepted
time: 1ms
memory: 3828kb
input:
5 12 187 184 1 1 0000000010101000000010000000000000100001000000000000000001000000010000000000000100100000000100000000010000000000000000100000000000010000010000000000000010000001000000100000000101000000 00000000000000000000000000000000000000010000000100000100000000000000000000000000000001010000000010...
output:
18087075 150234004 1259249 4715215 236348 571474 43837 64502 8531 8367
result:
ok 5 lines
Test #13:
score: 6
Accepted
time: 7ms
memory: 4060kb
input:
5 13 271 300 1 1 0000000100000010000000100000000110000000000100000001001000100100000000000000100001000100000001001000000000000000000000001000000000000000010100000000000000000000000100000000010000000000000000000000000001001000000000010000000000010000000001000000000000000000000010000000000010000000000...
output:
42365220 358193357 3095089 11638923 485642 1141183 95052 141468 20883 21431
result:
ok 5 lines
Test #14:
score: 8
Accepted
time: 19ms
memory: 5228kb
input:
5 14 500 476 1 1 0000000000000000001110000000010001000000000000000010000000000100000000000000100000000000001000000001000000000000100000001000001001101000000001000000000101000000000010000001100100000100000010100000000000000100100000000000000000001011000000000000011000000000000000000000000000010100001...
output:
132646140 185264487 9978992 39570487 1460852 3463881 290847 445053 50919 50710
result:
ok 5 lines
Test #15:
score: 6
Accepted
time: 65ms
memory: 12196kb
input:
5 15 995 999 1 0 0100000000000000000010000000000000000001000000000000000000000110000100000000000000000000000100000000000000000000001000000000000100000000100000000010000000010010000000000010000100100110000010000000000000000100000100000000000000001000010100000000000000000000000000010000000001000000000...
output:
569370923 0 40349163 0 6144080 0 1186094 0 249688 0
result:
ok 5 lines
Test #16:
score: 14
Accepted
time: 67ms
memory: 12148kb
input:
5 16 1000 998 1 1 010001000000000101000000100101000000000000000000100000000000000000000100000110010010000000100000000100000000000000000001000000000001000000010000000010000100000011000000000000000000010000000000000100000100000001000000010000000000000000000000000000000000000000000000000111001000000000...
output:
575874014 131845186 39748874 155407788 6206382 14467888 1175981 1745889 244602 238670
result:
ok 5 lines
Extra Test:
score: 0
Extra Test Passed