Submission #966788

# Submission time Handle Problem Language Result Execution time Memory
966788 2024-04-20T11:04:41 Z berr Kangaroo (CEOI16_kangaroo) C++17
0 / 100
16 ms 348 KB
#include <bits/stdc++.h>
using namespace std;
const int N = 2005;
int dp[N][N][2];

int calc(int n, int cs, int cf, int dir){

    if(n==2 && (cs<cf)==dir) return 1;
    else if(n==2) return 0;
    int v=0, check=0, ans=0;

    if(dir==0){
        for(int i=0; i<cs; i++, v++){
            if(i==cf){
                if(i==cf) check=1, v--;
                continue;
            }
            else{
                ans+=calc(n-1, v, cf-(cs<cf), 1);
            }
        }
    }
    else{
        int v=cs+1;
        if(cf<cs) v--;
        for(int i=cs+1; i<n; i++, v++){
            if(i==cf){
                v--;
                continue;
            }
            else{
                ans+=calc(n-1, v, cf-(cs<cf), 0);

            }
        }


    }

    return ans;
    
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
   freopen("kangaroo.in", "r", stdin);
    freopen("kangaroo.out", "w", stdout);

    int n, cs, cf; cin >> n >> cs >> cf;
    cs--; cf--;
    cout<<calc(n, cs, cf, 0)+calc(n, cs, cf, 1);
}

Compilation message

kangaroo.cpp: In function 'int calc(int, int, int, int)':
kangaroo.cpp:10:14: warning: variable 'check' set but not used [-Wunused-but-set-variable]
   10 |     int v=0, check=0, ans=0;
      |              ^~~~~
kangaroo.cpp: In function 'int main()':
kangaroo.cpp:46:11: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   46 |    freopen("kangaroo.in", "r", stdin);
      |    ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:47:12: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |     freopen("kangaroo.out", "w", stdout);
      |     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 16 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -