Submission #203596

# Submission time Handle Problem Language Result Execution time Memory
203596 2020-02-21T14:46:32 Z stefdasca Kangaroo (CEOI16_kangaroo) C++14
0 / 100
5 ms 376 KB
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n, a, b;
int add(int a, int b)
{
    int x = a+b;
    if(x >= mod)
        x -= mod;
    if(x < 0)
        x += mod;
    return x;
}
int dp[2][202][202][202];
int main()
{
    cin >> n >> a >> b;
    for(int i = 1; i <= n; ++i)
        if(i != a && i != b)
            dp[(a < i)][i - 1 - (a < i)][n - i - (a > i)][b - (a < b) - (i < b)] = 1;
    int ans = 0;
    for(int sum = n-2; sum >= 1; --sum)
    {
        for(int i = 0; i <= sum; ++i)
            for(int pos = 1; pos <= sum; ++pos)
            {
                int smaller = i;
                int bigger = sum - i;
              //  cout << sum << '\n';
              //  cout << smaller << " " << bigger << " " << pos << '\n';
              //  cout << dp[0][smaller][bigger][pos] << " " << dp[1][smaller][bigger][pos] << '\n';
                if(sum == 1)
                {
                    ans = add(ans, dp[0][smaller][bigger][1]);
                    ans = add(ans, dp[1][smaller][bigger][1]);
                }
                else
                    for(int relpos = 1; relpos <= sum; ++relpos)
                    {
                        if(pos == relpos)
                            continue;
                        if(relpos <= smaller)
                            dp[0][relpos - 1][sum - relpos][pos - (relpos < pos)] = add(dp[0][relpos - 1][sum - relpos][pos - (relpos < pos)],
                                                                                        dp[1][smaller][bigger][pos]);
                        else
                            dp[1][relpos - 1][sum - relpos][pos - (relpos < pos)] = add(dp[1][relpos - 1][sum - relpos][pos - (relpos < pos)],
                                                                                        dp[0][smaller][bigger][pos]);
                    }
            }
    }
    cout << ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Incorrect 5 ms 376 KB Output isn't correct