Submission #966788

#TimeUsernameProblemLanguageResultExecution timeMemory
966788berrKangaroo (CEOI16_kangaroo)C++17
0 / 100
16 ms348 KiB
#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 (stderr)

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 timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...