QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#83265#5162. 种花james1BadCreeper100 ✓420ms302176kbC++141.7kb2023-03-01 10:25:152023-03-01 10:25:16

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-03-01 10:25:16]
  • 评测
  • 测评结果:100
  • 用时:420ms
  • 内存:302176kb
  • [2023-03-01 10:25:15]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int P = 998244353; 

int n, m, VC, VF, C, F;   
char a[5005][5005];
int rig[5005][5005], up[5005][5005], down[5005][5005]; 

int main(void) {
    int T, id; scanf("%d%d", &T, &id);
    while (T--) {
        memset(rig, 0, sizeof rig); memset(up, 0, sizeof up); memset(down, 0, sizeof down);
        scanf("%d%d%d%d", &n, &m, &VC, &VF);
        for (int i = 1; i <= n; ++i) scanf("%s", a[i] + 1); 
        for (int i = n; i >= 1; --i) {
            rig[i][m] = (a[i][m] == '0' ? 1 : 0);
            for (int j = m - 1; j >= 1; --j) {
                if (a[i][j] == '1') rig[i][j] = 0; 
                else rig[i][j] = (rig[i][j + 1] + 1) % P; 
            }
        }
        for (int i = 2; i <= n; ++i)
            for (int j = 1; j <= m; ++j) {
                if (a[i][j] == '1') up[i][j] = 0; 
                else {
                    up[i][j] = up[i - 1][j]; 
                    if (a[i - 1][j] != '1') up[i][j] = (up[i][j] + rig[i - 1][j + 1]) % P; 
                }
            }
        for (int j = 1; j <= m; ++j) {
            down[n][j] = (a[n][j] == '0' ? 1 : 0);
            for (int i = n - 1; i >= 1; --i) {
                if (a[i][j] == '1') down[i][j] = 0; 
                else down[i][j] = (down[i + 1][j] + 1) % P; 
            }
        }
        C = F = 0; 
        for (int i = 1; i <= n; ++i)
            for (int j = 1; j <= m; ++j) if (a[i][j] != '1') {
                C = (C + 1ll * up[i - 1][j] * (rig[i][j] - 1) % P) % P; 
                F = (F + 1ll * up[i - 1][j] * (rig[i][j] - 1) % P * down[i + 1][j] % P) % P;
            }
        printf("%lld %lld\n", 1ll * C * VC, 1ll * F * VF);
    } 
    return 0;
}

这程序好像有点Bug,我给组数据试试?

詳細信息

Test #1:

score: 1
Accepted
time: 76ms
memory: 301980kb

input:

1 1
998 1000 0 0
0000100000100001000000000000011100000000010100100010000001100000000100011010000000011010001000100010000010001000011110010000000000010100000000001000000010000000100001000000101000010010010000000010010010000010001000010000000010000100001001001111010000000000010000000000100001111010011...

output:

0 0

result:

ok single line: '0 0'

Test #2:

score: 2
Accepted
time: 141ms
memory: 297040kb

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: 235ms
memory: 297308kb

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: 240ms
memory: 301056kb

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: 380ms
memory: 302176kb

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: 420ms
memory: 301936kb

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: 227ms
memory: 297336kb

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: 216ms
memory: 297184kb

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: 222ms
memory: 297196kb

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: 224ms
memory: 297504kb

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: 216ms
memory: 297688kb

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: 226ms
memory: 297912kb

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: 221ms
memory: 298328kb

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: 265ms
memory: 299292kb

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: 407ms
memory: 301932kb

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: 417ms
memory: 302152kb

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