QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#203605 | #5532. Kangaroo | Camillus | 0 | 1ms | 7584kb | C++20 | 1.7kb | 2023-10-06 18:35:50 | 2023-10-06 18:35:51 |
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 = 0; j < n; j++) {
for (int k = i + 1; k < n; k++) {
A[l][i][j] = A[l][i][j] + B[l - 1][k - 1][j - (j > i)];
}
for (int k = 0; k < i; k++) {
B[l][i][j] = B[l][i][j] + A[l - 1][k][j - (j > i)];
}
}
}
for (int i = 1; i < n; i++) {
for (int j = 0; j < n; j++) {
A[l][i][j] = B[l - 1][i - 1][j] - B[l - 1][i - 1][j - (j > i)];
B[l][i][j] = A[l - 1][i - 1][j] + A[l - 1][i - 1][j - (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: 1ms
memory: 7584kb
input:
7 3 6
output:
1000000005
result:
wrong answer 1st numbers differ - expected: '14', found: '1000000005'
Subtask #2:
score: 0
Skipped
Dependency #1:
0%
Subtask #3:
score: 0
Skipped
Dependency #1:
0%
Subtask #4:
score: 0
Skipped
Dependency #1:
0%