QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#131110 | #5162. 种花 | Heltion | 6 | 67ms | 8316kb | C++20 | 1.2kb | 2023-07-26 12:22:29 | 2023-07-26 12:22:31 |
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));
for (int i = 0; i < n; i += 1) {
for (int j = m - 1; j >= 0; j -= 1) {
if (s[i][j] == '1') {
r[i][j] = 0;
} else if (j + 1 < m) {
r[i][j] += r[i][j + 1];
}
}
}
i64 nc = 0, nf = 0;
for (int i = 0; i < m; i += 1) {
i64 s1 = 0, s2 = 0, s3 = 0;
for (int j = 0; j < n; j += 1) {
if (r[j][i]) {
if (j >= 2 and r[j - 2][i]) {
s1 = (s1 + r[j - 2][i] - 1) % mod;
}
s2 = (s2 + s1 * (r[j][i] - 1)) % mod;
nc = (nc + s1 * (r[j][i] - 1)) % mod;
nf = (nf + s3) % mod;
s3 = (s3 + s2) % mod;
} else {
s1 = s2 = s3 = 0;
}
}
}
cout << nc * c % mod << " " << nf * f % mod << "\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 1
Accepted
time: 12ms
memory: 8052kb
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: 3464kb
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: 3468kb
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: 0
Wrong Answer
time: 2ms
memory: 3612kb
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:
6005 332080 1719 25647 1147 12259 273 617 125 303
result:
wrong answer 1st lines differ - expected: '5301 38550', found: '6005 332080'
Test #5:
score: 0
Wrong Answer
time: 51ms
memory: 8188kb
input:
5 5 999 998 1 1 00100100100100101100100100100100100100100100110100110100101100100100110100100100100101100100110100100100101100101100101100100100100100100100101100101100110100100100110100100100100100100110100101110100101110100100110100100100100101100100100100100100101100100100100100100100100100100100...
output:
2170068 194832443 682223 13506632 266379 2050130 106945 395433 41752 79893
result:
wrong answer 1st lines differ - expected: '1952124 17488577', found: '2170068 194832443'
Test #6:
score: 0
Wrong Answer
time: 53ms
memory: 8148kb
input:
5 6 995 1000 1 1 0000000000100101000000000000000000001010000100000000000000000100100000000001000000000000000000100000000101000000000000000000000000000000000000000000000001000000000000000100100000001000000000010000000000000000000000000100000000100000001011000100000000110000000000000000000000000000000...
output:
58314592 51891966 8560110 6755472 2092197 1439179 592831 335500 169492 76077
result:
wrong answer 1st lines differ - expected: '14235129 0', found: '58314592 51891966'
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 3576kb
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:
6033 31928 633 1672 35 22 55 75 8 3
result:
wrong answer 1st lines differ - expected: '5890 12768', found: '6033 31928'
Test #8:
score: 0
Wrong Answer
time: 1ms
memory: 3508kb
input:
5 8 20 18 1 1 010010000010000000 000000000010000110 000000101000000000 000000000000001000 000000000000000000 000000010000000000 010000000010100000 000100000100000001 000000000000001010 000000000100000000 000000100000000001 000001000000100000 000000000100001010 100000000000000000 000000000000000100 0...
output:
36298 585566 13407 172506 645 1097 294 344 93 142
result:
wrong answer 1st lines differ - expected: '32999 126558', found: '36298 585566'
Test #9:
score: 0
Wrong Answer
time: 1ms
memory: 3532kb
input:
5 9 28 29 1 1 01000000000001000000000000100 00001000010000000000010000001 00000000000000000000000000001 00000100000000100001100100100 00001110100010100011000000000 00000000000000010000100010010 00001000000000000000000000000 00000000000000000010000000000 01000000000010000001001000010 0000100000001010...
output:
129002 3182847 15004 105894 5671 23768 886 1600 360 640
result:
wrong answer 1st lines differ - expected: '117502 565585', found: '129002 3182847'
Test #10:
score: 0
Wrong Answer
time: 1ms
memory: 3588kb
input:
5 10 48 50 1 1 01001000001000001000000000001000010000000000000000 00000000000000100000100101000000000000000001000000 00001000000100000100000000110000000000000000000000 00000000000000000000000000000001000100000000001001 00100000000000000000000100010000000010000000000100 001000000000000100000000101000...
output:
908506 59464990 99400 1202175 10141 43356 3596 10380 877 1385
result:
wrong answer 1st lines differ - expected: '847186 6581666', found: '908506 59464990'
Test #11:
score: 0
Wrong Answer
time: 2ms
memory: 3524kb
input:
5 11 95 90 1 1 001100000100000011000000000000000100000000000001000000000000000100000010000000000000000000 000000000000000000000000000000100000000000000000000100000000000000000000100000000010000000 000000000100000000011000000010001000000000000000000001100000010000000000100001000010000000 000000000000...
output:
3694975 291408792 406774 6872183 65906 397129 16523 55492 3565 4492
result:
wrong answer 1st lines differ - expected: '3308449 27745538', found: '3694975 291408792'
Test #12:
score: 0
Wrong Answer
time: 1ms
memory: 3740kb
input:
5 12 187 184 1 1 0000000010101000000010000000000000100001000000000000000001000000010000000000000100100000000100000000010000000000000000100000000000010000010000000000000010000001000000100000000101000000 00000000000000000000000000000000000000010000000100000100000000000000000000000000000001010000000010...
output:
20077278 529012735 1608814 29470647 337442 2902619 72978 253796 16493 31314
result:
wrong answer 1st lines differ - expected: '18087075 150234004', found: '20077278 529012735'
Test #13:
score: 0
Wrong Answer
time: 7ms
memory: 3756kb
input:
5 13 271 300 1 1 0000000100000010000000100000000110000000000100000001001000100100000000000000100001000100000001001000000000000000000000001000000000000000010100000000000000000000000100000000010000000000000000000000000001001000000000010000000000010000000001000000000000000000000010000000000010000000000...
output:
47241752 790216005 3921689 70562052 698026 5555171 159858 591141 40696 80325
result:
wrong answer 1st lines differ - expected: '42365220 358193357', found: '47241752 790216005'
Test #14:
score: 0
Wrong Answer
time: 13ms
memory: 4456kb
input:
5 14 500 476 1 1 0000000000000000001110000000010001000000000000000010000000000100000000000000100000000000001000000001000000000000100000001000001001101000000001000000000101000000000010000001100100000100000010100000000000000100100000000000000000001011000000000000011000000000000000000000000000010100001...
output:
147520234 271484859 12485883 250343034 2074161 16518692 482361 1876277 102546 202099
result:
wrong answer 1st lines differ - expected: '132646140 185264487', found: '147520234 271484859'
Test #15:
score: 0
Wrong Answer
time: 66ms
memory: 8316kb
input:
5 15 995 999 1 0 0100000000000000000010000000000000000001000000000000000000000110000100000000000000000000000100000000000000000000001000000000000100000000100000000010000000010010000000000010000100100110000010000000000000000100000100000000000000001000010100000000000000000000000000010000000001000000000...
output:
633276153 0 50401236 0 8794098 0 1978240 0 495771 0
result:
wrong answer 1st lines differ - expected: '569370923 0', found: '633276153 0'
Test #16:
score: 0
Wrong Answer
time: 67ms
memory: 8208kb
input:
5 16 1000 998 1 1 010001000000000101000000100101000000000000000000100000000000000000000100000110010010000000100000000100000000000000000001000000000001000000010000000010000100000011000000000000000000010000000000000100000100000001000000010000000000000000000000000000000000000000000000000111001000000000...
output:
639994177 741803071 49716779 949871864 8857031 68858370 1959626 7262848 486098 937929
result:
wrong answer 1st lines differ - expected: '575874014 131845186', found: '639994177 741803071'