# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
548359 | krit3379 | Kangaroo (CEOI16_kangaroo) | C++17 | 1 ms | 340 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include<bits/stdc++.h>
using namespace std;
#define N 205
int a[N][N][N],d[N][N][N],mod=1e9+7;
int main(){
int n,s,e,i,j,k,l;
scanf("%d %d %d",&n,&s,&e);
if(n==2){
printf("1");
return 0;
}
a[2][1][2]=1;
d[2][2][1]=1;
for(i=3;i<=n;i++){
for(j=1;j<=i;j++){
for(k=1;k<=i;k++){
if(j==k){
a[i][j][k]=(a[i][j][k]+a[i][j-1][k])%mod;
d[i][j][k]=(d[i][j][k]+d[i][j-1][k])%mod;
continue;
}
a[i][j][k]=(d[i-1][i-1][k-(j<k)]-d[i-1][j-1][k-(j<k)]+mod)%mod;
if(j<k)a[i][j][k]=(a[i][j][k]-(d[i-1][k-1][k-(j<k)]-(k>1)?d[i-1][k-2][k-(j<k)]:0)%mod+mod)%mod;
d[i][j][k]=a[i-1][j-1][k-(j<k)];
if(j>k)d[i][j][k]=(d[i][j][k]-(a[i-1][k][k-(j<k)]-a[i-1][k-1][k-(j<k)])%mod+mod)%mod;
if(i==n&&j==s&&k==e){
printf("%d",(a[i][j][k]+d[i][j][k])%mod);
}
a[i][j][k]=(a[i][j][k]+a[i][j-1][k])%mod;
d[i][j][k]=(d[i][j][k]+d[i][j-1][k])%mod;
}
}
}
return 0;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |