Submission #222702

# Submission time Handle Problem Language Result Execution time Memory
222702 2020-04-13T19:24:35 Z Minnakhmetov Kangaroo (CEOI16_kangaroo) C++14
0 / 100
5 ms 512 KB
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define all(aaa) aaa.begin(), aaa.end()
 
const int N = 205, MOD = 1e9 + 7;
int dp[N][N][N][2], pref[N][N][N][2];
 
void add(int &a, int b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}
 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
 
    int n, cs, cf;
    cin >> n >> cs >> cf;

    if (cf > cs)
    	swap(cf, cs);
 
    dp[2][2][1][1]++;
    dp[2][1][2][0]++;
 
    pref[2][2][1][1]++;
    pref[2][2][2][1]++;
    pref[2][1][2][0]++;
 
    for (int i = 3; i <= n; i++) {
        for (int k = 1; k <= i; k++) {
    	   for (int j = k + 1; j <= i; j++) {
                add(dp[i][k][j][0], pref[i - 1][k][j - 1][1]);
                add(dp[i][k][j][1], pref[i - 1][k][i - 1][0]);
                add(dp[i][k][j][1], MOD - pref[i - 1][k][j - 1][0]);
                add(dp[i][k][j][1], pref[i - 1][k][k][0]);
                add(dp[i][k][j][1], MOD - pref[i - 1][i - 1 - k][i - 1 - k][1]);
    		}
 
            for (int j = 1; j < k; j++) {
                dp[i][k][j][0] = dp[i][j][k][(i & 1) ^ 1];
                dp[i][k][j][1] = dp[i][j][k][(i & 1)];
            }
 
            for (int j = 1; j <= i; j++) {
                pref[i][k][j][0] = pref[i][k][j - 1][0];
                pref[i][k][j][1] = pref[i][k][j - 1][1];
                add(pref[i][k][j][0], dp[i][k][j][0]);
                add(pref[i][k][j][1], dp[i][k][j][1]);
            }
    	}
    }
 
    int ans = (dp[n][cf][cs][0] + dp[n][cf][cs][1]) % MOD;
 
    cout << ans;
 
    // for (int i = 1; i <= n; i++) {
    //     for (int j = 1; j <= n; j++) {
 
    //         cout << dp[n][i][j][0] << " ";
    //     }
    //     cout << "\n";
    // }
 
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Incorrect 5 ms 512 KB Output isn't correct