QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203624 | #5532. Kangaroo | Camillus | 0 | 0ms | 7836kb | C++20 | 2.2kb | 2023-10-06 18:45:01 | 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%