QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203628#5532. KangarooCamillus51 16ms81564kbC++202.2kb2023-10-06 18:50:262023-10-06 18:50:27

Judging History

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

  • [2023-10-06 18:50:27]
  • 评测
  • 测评结果:51
  • 用时:16ms
  • 内存:81564kb
  • [2023-10-06 18:50:26]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

struct mint {
    static constexpr int mod = 1'000'000'007;
    int value = 0;

    mint() = default;
    mint(int value) : value(value) {}
};

mint operator+(const mint &A, const mint &B) {
    int value = A.value + B.value;
    if (value >= mint::mod) {
        value -= mint::mod;
    }
    return mint(value);
}

mint operator-(const mint &A, const mint &B) {
    int value = A.value + mint::mod - B.value;
    if (value >= mint::mod) {
        value -= mint::mod;
    }
    return mint(value);
}

mint operator*(const mint &A, const mint &B) {
    return mint(1ll * A.value * B.value % mint::mod);
}

mint A[300][300][300];
mint B[300][300][300];

signed main() {
#ifndef LOCAL
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#else
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    A[1][0][0] = 1;
    B[1][0][0] = 1;

    int n, s, f;
    cin >> n >> s >> f;
    s--, f--;

    for (int l = 2; l <= n; l++) {
        for (int i : {0}) {
            for (int j = i + 1; j < l; j++) {
                if (i == j) {
                    continue;
                }
                for (int k = i + 1; k < l; k++) {
                    A[l][i][j] = A[l][i][j] + B[l - 1][k - 1][j - 1];
                }
                for (int k = 0; k < i; k++) {
                    B[l][i][j] = B[l][i][j] + A[l - 1][k][j - 1];
                }
            }
        }
        for (int i = 1; i < l; i++) {
            for (int j = i + 1; j < l; j++) {
                if (i == j) {
                    continue;
                }
                A[l][i][j] = A[l][i - 1][j] - B[l - 1][i - 1][j - 1];
                B[l][i][j] = B[l][i - 1][j] + A[l - 1][i - 1][j - 1];
            }
        }
        for (int i = 1; i < l; i++) {
            for (int j = 0; j < i; j++) {
                if (l % 2 == 0) {
                    A[l][i][j] = B[l][j][i];
                    B[l][i][j] = A[l][j][i];
                } else {
                    A[l][i][j] = A[l][j][i];
                    B[l][i][j] = B[l][j][i];
                }
            }
        }
    }

    cout << (A[n][s][f] + B[n][s][f]).value << '\n';
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Subtask #1:

score: 6
Accepted

Test #1:

score: 6
Accepted
time: 1ms
memory: 7760kb

input:

7 3 6

output:

14

result:

ok 1 number(s): "14"

Subtask #2:

score: 30
Accepted

Dependency #1:

100%
Accepted

Test #2:

score: 30
Accepted
time: 0ms
memory: 11612kb

input:

39 36 32

output:

964903316

result:

ok 1 number(s): "964903316"

Test #3:

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

input:

26 1 26

output:

955348527

result:

ok 1 number(s): "955348527"

Test #4:

score: 0
Accepted
time: 2ms
memory: 9736kb

input:

40 11 33

output:

695661890

result:

ok 1 number(s): "695661890"

Test #5:

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

input:

39 39 38

output:

717149364

result:

ok 1 number(s): "717149364"

Test #6:

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

input:

40 10 25

output:

912929610

result:

ok 1 number(s): "912929610"

Test #7:

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

input:

37 25 23

output:

250748685

result:

ok 1 number(s): "250748685"

Test #8:

score: 0
Accepted
time: 2ms
memory: 9524kb

input:

39 2 38

output:

624060592

result:

ok 1 number(s): "624060592"

Test #9:

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

input:

40 18 22

output:

739993796

result:

ok 1 number(s): "739993796"

Test #10:

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

input:

40 11 35


output:

135213497

result:

ok 1 number(s): "135213497"

Subtask #3:

score: 15
Accepted

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Test #11:

score: 15
Accepted
time: 8ms
memory: 78048kb

input:

199 100 70

output:

914653136

result:

ok 1 number(s): "914653136"

Test #12:

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

input:

187 3 40

output:

928785584

result:

ok 1 number(s): "928785584"

Test #13:

score: 0
Accepted
time: 3ms
memory: 81564kb

input:

199 198 197

output:

38412688

result:

ok 1 number(s): "38412688"

Test #14:

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

input:

200 40 140

output:

367088143

result:

ok 1 number(s): "367088143"

Test #15:

score: 0
Accepted
time: 3ms
memory: 81252kb

input:

199 111 3

output:

870834793

result:

ok 1 number(s): "870834793"

Test #16:

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

input:

200 133 73

output:

343127012

result:

ok 1 number(s): "343127012"

Test #17:

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

input:

178 15 163

output:

160852284

result:

ok 1 number(s): "160852284"

Test #18:

score: 0
Accepted
time: 7ms
memory: 76400kb

input:

197 43 79

output:

332057544

result:

ok 1 number(s): "332057544"

Test #19:

score: 0
Accepted
time: 16ms
memory: 80580kb

input:

200 33 79

output:

742545318

result:

ok 1 number(s): "742545318"

Subtask #4:

score: 0
Runtime Error

Dependency #1:

100%
Accepted

Dependency #2:

100%
Accepted

Dependency #3:

100%
Accepted

Test #20:

score: 0
Runtime Error

input:

658 169 438

output:


result: