답안 #1005386

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005386 2024-06-22T11:45:08 Z SulA 캥거루 (CEOI16_kangaroo) C++14
36 / 100
4 ms 1480 KB
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N,cs,cf; cin >> N >> cs >> cf;
    if (N > 40) return cout << 0, 0;
    --cs, --cf;
    long long dp[2][N+1][N][N];
    memset(dp, 0, sizeof dp);

    dp[0][1][0][0] = dp[1][1][0][0] = 1;
    for (int n = 2; n <= N; n++) {
        for (int s = 0; s < n; s++) {
            for (int f = 0; f < n; f++) {
                if (s == f) continue;

                // finding dp[0][...]
                // 0 = right-to-left
                // 1 = left-to-right
                dp[0][n][s][f] = dp[1][n][s][f] = 0;
                for (int p = s+1; p < n; p++) {
                    (dp[0][n][s][f] += dp[1][n-1][p-1][f-(f > s)]) %= MOD;
                }
                for (int p = s-1; p >= 0; p--) {
                    (dp[1][n][s][f] += dp[0][n-1][p][f-(f > s)]) %= MOD;
                }
            }
        }
    }
    cout << (dp[0][N][cs][cf] + dp[1][N][cs][cf]) % MOD;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 2 ms 1368 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 2 ms 1372 KB Output is correct
9 Correct 3 ms 1372 KB Output is correct
10 Correct 3 ms 1480 KB Output is correct
11 Correct 3 ms 1368 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 2 ms 1368 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 2 ms 1372 KB Output is correct
9 Correct 3 ms 1372 KB Output is correct
10 Correct 3 ms 1480 KB Output is correct
11 Correct 3 ms 1368 KB Output is correct
12 Incorrect 0 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 4 ms 1372 KB Output is correct
5 Correct 2 ms 1368 KB Output is correct
6 Correct 3 ms 1372 KB Output is correct
7 Correct 2 ms 1116 KB Output is correct
8 Correct 2 ms 1372 KB Output is correct
9 Correct 3 ms 1372 KB Output is correct
10 Correct 3 ms 1480 KB Output is correct
11 Correct 3 ms 1368 KB Output is correct
12 Incorrect 0 ms 344 KB Output isn't correct
13 Halted 0 ms 0 KB -