QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#227860#5532. KangarooCamillus0 1ms3416kbC++203.0kb2023-10-28 01:09:492023-10-28 01:09:49

Judging History

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

  • [2023-10-28 01:09:49]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3416kb
  • [2023-10-28 01:09:49]
  • 提交

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 recA(int l, int i, int j);
mint recB(int l, int i, int j);

namespace AA {

};

map<tuple<int, int, int>, mint> savedA;

mint recA(int l, int i, int j) {
    if (i > j) {
        if (l % 2 == 0) {
            return recB(l, j, i);
        } else {
            return recA(l, j, i);
        }
    }

    if (savedA.contains(tuple(l, i, j))) {
        return savedA[tuple(l, i, j)];
    }
    
    if (l == 1) {
        if (i == 0 && j == 0) {
            return 1;
        } else {
            return 0;
        }
    }
    
    if (i == j) {
        return 0;
    }

    if (i == 0) {
        mint res = 0;
        if (l % 2 == 0) {
            if (j == 1) {
                for (int k = j; k < l - 1; k++) {
                    res = res + recB(l - 1, 0, k);
                }
            } else {
                res = recA(l, 0, j - 1) + recA(l - 1, 0, j - 1);
            }
        } else {
            if (j == 1) {
                for (int k = j; k <= l - 2; k++) {
                    res = res + recA(l - 1, 0, k);
                }
            } else {
                res = recA(l, 0, j - 1) - recA(l - 1, 0, j - 1);
            }
        }
        return savedA[tuple(l, i, j)] = res;
    }

    return savedA[tuple(l, i, j)] = recA(l, i - 1, j) - recB(l - 1, i - 1, j - 1);
}

map<tuple<int, int, int>, mint> savedB;

mint recB(int l, int i, int j) {
    if (i > j) {
        if (l % 2 == 0) {
            return recA(l, j, i);
        } else {
            return recB(l, j, i);
        }
    }

    if (savedB.contains(tuple(l, i, j))) {
        return savedB[tuple(l, i, j)];
    }

    if (l == 1) {
        if (i == 0 && j == 0) {
            return 1;
        } else {
            return 0;
        }
    }
    
    if (i == j) {
        return 0;
    }

    if (i == 0) {
        return savedB[tuple(l, i, j)] = 0;
    }

    return savedB[tuple(l, i, j)] = recB(l, i - 1, j) + recA(l - 1, i - 1, j - 1);
}

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

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

    cout << (recA(n, s, f) + recB(n, s, f)).value << '\n';
    return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 1ms
memory: 3416kb

input:

7 3 6

output:

0

result:

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

Subtask #2:

score: 0
Skipped

Dependency #1:

0%

Subtask #3:

score: 0
Skipped

Dependency #1:

0%

Subtask #4:

score: 0
Skipped

Dependency #1:

0%