QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#523120#9174. Game Designhhu_yjhTL 363ms101576kbC++14963b2024-08-17 20:40:082024-08-17 20:40:08

Judging History

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

  • [2024-08-17 20:40:08]
  • 评测
  • 测评结果:TL
  • 用时:363ms
  • 内存:101576kb
  • [2024-08-17 20:40:08]
  • 提交

answer

    #include<bits/stdc++.h>

    using namespace std;
    const int N=2e5+10,mod=998244353;
    int n, m, k;

    void solve() {
        string s;
        cin >> s;
        n = s.size();
        vector<vector<int>> dp(5000+10, vector<int>(5000+10));
        dp[0][0] = 1;
        for (int i = 1; i <= n; i++) {
            dp[i].assign(n + 1, 0);
            for (int j = 0; j <= i; j++) {
                dp[i][j] = (1ll * j * dp[i-1][j] + (j ? dp[i-1][j - 1] : 0)) % mod;
                if (s[i - 1] == '1') {
                    dp[i][j] = (dp[i][j] + 1ll * j * dp[i-1][j] + 1ll * (j + 1) * (j + 1) * dp[i-1][j + 1]) % mod;
                }
            }
        }
        cout << dp[n][0] << endl;
    }

    int main() {  
        cin.tie(0);
        cout.tie(0);
        ios::sync_with_stdio(0);
        int _;
        _ = 1;
        cin >> _;
        while(_ --) {
            solve();
        }
        return 0;
    }

详细

Test #1:

score: 100
Accepted
time: 4ms
memory: 101420kb

input:

4
0101
1010010010001010
11111
10100100011000010010101001001001

output:

3
0
44
393298077

result:

ok 4 number(s): "3 0 44 393298077"

Test #2:

score: 0
Accepted
time: 24ms
memory: 101368kb

input:

4
01
11
10
00

output:

1
1
0
0

result:

ok 4 number(s): "1 1 0 0"

Test #3:

score: 0
Accepted
time: 63ms
memory: 101368kb

input:

8
011
110
100
000
010
101
111
001

output:

2
0
0
0
0
1
2
1

result:

ok 8 numbers

Test #4:

score: 0
Accepted
time: 76ms
memory: 101376kb

input:

16
0111
0110
0000
1001
1100
0011
0100
1110
1011
0001
1000
0010
1111
0101
1010
1101

output:

9
0
0
1
0
6
0
0
6
1
0
0
9
3
0
3

result:

ok 16 numbers

Test #5:

score: 0
Accepted
time: 183ms
memory: 101576kb

input:

32
01100
10010
11011
10100
00100
01010
10000
01111
11000
01001
00101
00011
11001
11111
10001
00000
00111
11101
11010
10110
10111
01101
10011
11100
01110
00001
01000
10101
01011
00010
00110
11110

output:

0
0
22
0
0
0
0
44
0
3
7
14
3
44
1
0
33
11
0
0
33
11
14
0
0
1
0
7
22
0
0
0

result:

ok 32 numbers

Test #6:

score: 0
Accepted
time: 363ms
memory: 101356kb

input:

64
001000
011100
101100
001101
011110
100000
000000
001111
000101
110111
010001
101111
001001
011111
111100
010011
100010
000001
010110
111111
111101
110101
111010
011010
110110
101000
101110
010010
011011
010000
100110
001010
101010
100111
100100
100101
110000
010111
011000
110011
000100
101001
111...

output:

0
0
0
39
0
0
0
212
15
159
3
212
7
265
0
50
0
1
0
265
53
25
0
0
0
0
0
0
106
0
0
0
0
117
0
15
0
159
0
50
0
7
0
0
25
53
3
117
30
11
39
78
0
0
30
0
0
1
0
11
78
106
0
0

result:

ok 64 numbers

Test #7:

score: -100
Time Limit Exceeded

input:

128
0111100
0110000
1010010
1001001
1010110
0011101
0100100
1100110
0110101
1001110
0101110
1111011
0100101
0111110
1001011
0110010
1111000
0101111
1101011
1001000
1110100
1000011
1001111
1101000
0100000
0010010
1100000
1011000
0100111
1001101
1010111
0111101
1110011
0101011
0001110
0010100
0011110
...

output:

0
0
0
15
0
245
0
0
117
0
0
618
53
0
262
0
0
1236
362
0
0
62
980
0
0
0
0
0
543
131
735
309
234
362
0
0
0
1545
0
11
7
1236
0
170
25
15
0
3
490
0
735
0
0
0
0
106
0
618
0
1854
85
393
0
0
106
0
7
31
0
62
39
0
31
0

result: