QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#456207#7129. Independent setpropaneAC ✓551ms439676kbC++201.7kb2024-06-27 13:44:522024-06-27 13:44:53

Judging History

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

  • [2024-06-27 13:44:53]
  • 评测
  • 测评结果:AC
  • 用时:551ms
  • 内存:439676kb
  • [2024-06-27 13:44:52]
  • 提交

answer

#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const int mod = 1e9 + 7;

void add(int &a, int b){
    a += b;
    if (a >= mod) a -= mod;
}

int mul(int a, int b){
    return 1LL * a * b % mod;
}

int dp[5000005][2][11], sum[11];

void conv(int *a, int *b){
    static ULL tmp[11];
    memset(tmp, 0, sizeof tmp);
    for(int i = 0; i <= 10; i++){
        for(int j = 0; i + j <= 10; j++){
            tmp[i + j] += 1ull * a[i] * b[j];
        }
    }
    for(int i = 0; i <= 10; i++) a[i] = tmp[i] % mod;
}

int main(){

#ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);

    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    for(int u = n; u >= 1; u--){
        dp[u][0][0] = 1;
        if (2 * u <= n){
            for(int i = 0; i <= 10; i++){
                dp[u][0][i] = dp[2 * u][0][i] + dp[2 * u][1][i];
                if (dp[u][0][i] >= mod) dp[u][0][i] -= mod;
            }
            if (2 * u + 1 <= n){
                for(int i = 0; i <= 10; i++){
                    sum[i] = dp[2 * u + 1][0][i] + dp[2 * u + 1][1][i];
                }
                conv(dp[u][0], sum);
            }
        }
        if (s[u - 1] == '0'){
            for(int i = 1; i <= 10; i++){
                dp[u][1][i] = 1;
            }
            if (2 * u <= n){
                conv(dp[u][1], dp[2 * u][0]);
                if (2 * u + 1 <= n){
                    conv(dp[u][1], dp[2 * u + 1][0]);
                }
            }
        }
    }
    cout << (dp[1][0][m] + dp[1][1][m]) % mod << '\n';

}

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

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3432kb

input:

2 2
00

output:

2

result:

ok 1 number(s): "2"

Test #2:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

10 3
0101010101

output:

26

result:

ok 1 number(s): "26"

Test #3:

score: 0
Accepted
time: 0ms
memory: 3804kb

input:

10 3
0000100000

output:

110

result:

ok 1 number(s): "110"

Test #4:

score: 0
Accepted
time: 0ms
memory: 3808kb

input:

10 3
0001000000

output:

117

result:

ok 1 number(s): "117"

Test #5:

score: 0
Accepted
time: 0ms
memory: 3740kb

input:

10 3
0010000001

output:

86

result:

ok 1 number(s): "86"

Test #6:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

10 3
0100000000

output:

115

result:

ok 1 number(s): "115"

Test #7:

score: 0
Accepted
time: 0ms
memory: 3432kb

input:

10 3
0010000000

output:

118

result:

ok 1 number(s): "118"

Test #8:

score: 0
Accepted
time: 0ms
memory: 3448kb

input:

10 3
1011001000

output:

45

result:

ok 1 number(s): "45"

Test #9:

score: 0
Accepted
time: 0ms
memory: 3520kb

input:

10 3
0000011001

output:

49

result:

ok 1 number(s): "49"

Test #10:

score: 0
Accepted
time: 0ms
memory: 3592kb

input:

10 3
0000010011

output:

48

result:

ok 1 number(s): "48"

Test #11:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

10 3
0100100101

output:

35

result:

ok 1 number(s): "35"

Test #12:

score: 0
Accepted
time: 0ms
memory: 3620kb

input:

10 3
0000000011

output:

72

result:

ok 1 number(s): "72"

Test #13:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

1000 10
0000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

876560614

result:

ok 1 number(s): "876560614"

Test #14:

score: 0
Accepted
time: 0ms
memory: 3820kb

input:

1000 10
0000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000010000000000000000000000000000000100000000000000010000000000000000000000001000000010000001000000000000000000000000000000000000000000000000000000000000...

output:

45119364

result:

ok 1 number(s): "45119364"

Test #15:

score: 0
Accepted
time: 0ms
memory: 3892kb

input:

1000 10
1100000010000000000010011100000000001000001101001010010000100100001000000000001010010100100000001001000000000000000010000010000001010000000000100000100000000000010100010000110000010010001000000000001000001000000000010001011010000000100100000000001010001110000010000000000000000000000000000000...

output:

460336587

result:

ok 1 number(s): "460336587"

Test #16:

score: 0
Accepted
time: 0ms
memory: 3512kb

input:

1000 10
0000000100000001000010001100000000000100000011000000000110100111000000100000000001000000000100100100010010011000010000010010001000100100000000000000100000100000010000000100000000000100001000000000000000000010000000001000010001000000010010000000000000000000100001000100000001000010100100011010...

output:

48086189

result:

ok 1 number(s): "48086189"

Test #17:

score: 0
Accepted
time: 0ms
memory: 3792kb

input:

1000 10
0010000000001000000001011000000000000000000000000000000000000001000010000001011000000000000000000000000000000010000010010000010000100001000001000000110000000000000100000000000000001001000000001000000001010000001001000000000000000000000000000000000010000000000010000001100001000000000100000110...

output:

512493587

result:

ok 1 number(s): "512493587"

Test #18:

score: 0
Accepted
time: 0ms
memory: 3640kb

input:

1000 10
0000000010000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000...

output:

412295689

result:

ok 1 number(s): "412295689"

Test #19:

score: 0
Accepted
time: 0ms
memory: 3788kb

input:

1000 10
0000100111000011101000000000010110000001100001100100000000000000001001000000010000100000010000010000000000100000000001000001000000010000000000110000100001000000001010010000000000110101100000100000101000110100001001000000101000000000000000010000001000100000000100001001010010010001000000000000...

output:

518455593

result:

ok 1 number(s): "518455593"

Test #20:

score: 0
Accepted
time: 0ms
memory: 3588kb

input:

1000 10
0000000100000000001000000000000000000000000000000001000000000000000010000000000010000000000000000000000000100100010000000110000000000000000000000000000010000000000000100000000100000000000000000000100010000000000100000000010010001000000000000000000000000000000000000000000000000000001000010000...

output:

430339412

result:

ok 1 number(s): "430339412"

Test #21:

score: 0
Accepted
time: 0ms
memory: 3528kb

input:

1000 10
0000110010000000000010101001010000100010010110000100001000100001000000000010000100000011100000000000010100001000000000000000100000100001100000001000000111100000100101001000000000000000001000001000100000000010000000001000001000000000001000000000000000001000100100001100100000011010001000000011...

output:

348316472

result:

ok 1 number(s): "348316472"

Test #22:

score: 0
Accepted
time: 1ms
memory: 3512kb

input:

1000 10
0000100000000010000000000000000000000000000000000001000010000010001010010000000000000000100100100100101101001001010000100000000000100000000000000100001010011100000001000000000010000000001000001001000001010001001000000010000000110000010000000000000000000101000001100000100000100000001010001000...

output:

213483490

result:

ok 1 number(s): "213483490"

Test #23:

score: 0
Accepted
time: 86ms
memory: 91784kb

input:

1000000 10
1000000000100011011000001001000100000111000100001001000000000000000000000010100000010000000000000001100110010100011010001000100100001101010010101100001100100110001100010001000000000000011000001000010100000100000110001101000000000100110000100000100001000010000001000010000100001000000011110...

output:

476845308

result:

ok 1 number(s): "476845308"

Test #24:

score: 0
Accepted
time: 107ms
memory: 91952kb

input:

1000000 10
0000000000000000000000000000000001000000100000000000000000000000000000000000000000000100000000010000000010000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000100001010000000000000000000000000000000000000000000000000100000010000100000010...

output:

774002748

result:

ok 1 number(s): "774002748"

Test #25:

score: 0
Accepted
time: 95ms
memory: 91656kb

input:

1000000 10
0000000000000000000001000000010000010010100110110001000100010000100000000111001000000000000001010000101000000000011000101000100000000000000000000000110010000000111001010000000000010000110000000100100000000001001001001001000010010001010000000000000000100001000000000000001100000100000000000...

output:

160255662

result:

ok 1 number(s): "160255662"

Test #26:

score: 0
Accepted
time: 95ms
memory: 91000kb

input:

1000000 10
0000000010000000000000100000000000000010000100001000000000000000000000100000100000000000000000000000000000100000000000000000011000000011000000001010000000000011000010111000010000000000000000000010000000000000000010000000000000000000010000010000100000001000000000000000010001000001000000000...

output:

707886122

result:

ok 1 number(s): "707886122"

Test #27:

score: 0
Accepted
time: 104ms
memory: 90160kb

input:

1000000 10
0100100000000000000000000000000100000000000100100000000000010000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000011000000000000000000000000000010000000000000000000000100000100000000000000000000000000000000000010000100000010000000000000000...

output:

979709914

result:

ok 1 number(s): "979709914"

Test #28:

score: 0
Accepted
time: 550ms
memory: 437956kb

input:

5000000 10
0000000000000000001000000000010000001000000000000000001000010000000000000000000000000000000000000000000000000000000000100000000000000000010001000000100000000000011000000000000000000001000000001000000000000000000000000000000000000000000000000001000000000000000000000001000100010000000001000...

output:

285627161

result:

ok 1 number(s): "285627161"

Test #29:

score: 0
Accepted
time: 521ms
memory: 438748kb

input:

5000000 10
0000000000000000000010000000010000000010000000000000000000000000000000000000000000000010000000000000000000000000001000000000000100000000000010000000000000000011000000000000000000000000000000000000000000000000000000000000000000010000000000000000010100100000010000000000000000000010000000000...

output:

303121972

result:

ok 1 number(s): "303121972"

Test #30:

score: 0
Accepted
time: 551ms
memory: 437980kb

input:

5000000 10
0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000...

output:

840451042

result:

ok 1 number(s): "840451042"

Test #31:

score: 0
Accepted
time: 515ms
memory: 439676kb

input:

5000000 10
0001001100000000000000000000000001000000000000010000000011000000000000000000000000010000000000000000000000000001001010000000100000000000000100000000000010101000010000010001000100000100000000000101000000010000000001010010000000000010100000000010000011000000000000000000000000000001000000000...

output:

5553929

result:

ok 1 number(s): "5553929"

Test #32:

score: 0
Accepted
time: 504ms
memory: 438864kb

input:

5000000 10
0000000000000000010000000000000000000000010000000000001000010100010010000110000000000000100010000000000000100000000000000010000000000000100000000000001100000000000000000000000000000100000000000000000000000000001010000000000100100000000000000000000000001000010100100011000000000000000000001...

output:

996917998

result:

ok 1 number(s): "996917998"