Submission #966418

#TimeUsernameProblemLanguageResultExecution timeMemory
966418vjudge1Kangaroo (CEOI16_kangaroo)C++17
100 / 100
13 ms31584 KiB
// In the name of Almighty Allah.
// We're nothing and you're everything.
// Allahu Akbar

#include <bits/stdc++.h>
using namespace std;

#define PI acos(-1.0)
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long ll;
typedef pair<int,int> pii;
typedef tuple<int,int,int> tii;

const int N = 2e3+5;
const ll mod = 1e9+7;

ll dp[N][N];

void solve(int tc){
	ll i,j,k,n,m,x,y,s,f,l;
	cin >> n >> s >> f;
	for(i=1;i<=n;i++){
		for(j=1;j<=i;j++){
			if(i == 1 && j == 1) dp[i][j] = 1;
			else if(i == s || i == f){
				dp[i][j] = dp[i-1][j-1] + dp[i-1][j];
			}
			else{
				x = j;
				if(i>s) x--;
				if(i>f) x--;
				dp[i][j] = dp[i-1][j+1]*j + dp[i-1][j-1]*x;
			}
			dp[i][j] %= mod;
		}
	}
	cout << dp[n][1] << "\n";
}

int main(){
	FAST_IO
	int t = 1;
	//cin >> t;
	for(int tc = 1;tc<=t;tc++){
		solve(tc);
	}
return 0;		
}

Compilation message (stderr)

kangaroo.cpp: In function 'void solve(int)':
kangaroo.cpp:20:9: warning: unused variable 'k' [-Wunused-variable]
   20 |  ll i,j,k,n,m,x,y,s,f,l;
      |         ^
kangaroo.cpp:20:13: warning: unused variable 'm' [-Wunused-variable]
   20 |  ll i,j,k,n,m,x,y,s,f,l;
      |             ^
kangaroo.cpp:20:17: warning: unused variable 'y' [-Wunused-variable]
   20 |  ll i,j,k,n,m,x,y,s,f,l;
      |                 ^
kangaroo.cpp:20:23: warning: unused variable 'l' [-Wunused-variable]
   20 |  ll i,j,k,n,m,x,y,s,f,l;
      |                       ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...