Submission #966789

# Submission time Handle Problem Language Result Execution time Memory
966789 2024-04-20T11:11:45 Z berr Kangaroo (CEOI16_kangaroo) C++17
0 / 100
3 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;
    if(dir==0&&cs==0||dir==1&&cs==n-1) return 0;

    int v=0, check=0, ans=0;

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


    }
    //cout<<n<<" "<<cs<<" "<<cf<<" "<<dir<<" "<<ans<<"\n";
    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: suggest parentheses around '&&' within '||' [-Wparentheses]
   10 |     if(dir==0&&cs==0||dir==1&&cs==n-1) return 0;
      |        ~~~~~~^~~~~~~
kangaroo.cpp:12:14: warning: unused variable 'check' [-Wunused-variable]
   12 |     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 3 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -