QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#203624#5532. KangarooCamillus0 0ms7836kbC++202.2kb2023-10-06 18:45:012023-10-06 18:45:01

Judging History

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

  • [2023-10-06 18:45:01]
  • 评测
  • 测评结果:0
  • 用时:0ms
  • 内存:7836kb
  • [2023-10-06 18:45:01]
  • 提交

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;
    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: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 7836kb

input:

7 3 6

output:

410065485

result:

wrong answer 1st numbers differ - expected: '14', found: '410065485'

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%