# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
163338 | ryansee | Kangaroo (CEOI16_kangaroo) | C++14 | 117 ms | 76680 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 <cstdio>
#include <iostream>
#define MOD 1000000007
using namespace std;
int c[210][210][210] , d[210][210][210];
int main()
{
FILE *fin = stdin;
FILE *fout = stdout;
int n , cs , cf , len , bgn , ed;
fscanf (fin,"%d%d%d",&n,&cs,&cf);
c[2][1][2] = d[2][2][1] = 1;
for (len = 3 ; len <= n ; len++){
for (bgn = 1 ; bgn <= len ; bgn++){
for (ed = bgn + 1 ; ed <= len ; ed ++){
if (bgn!=1)
c[len][bgn][ed] = ((c[len][bgn-1][ed] - d[len-1][bgn-1][ed-1])%MOD + MOD )%MOD;
else {
for (int bgn2 = bgn+1 ; bgn2 <= len ; bgn2++)
c[len][bgn][ed] = (c[len][bgn][ed] + d[len-1][bgn2][ed-1])%MOD;
}
d[len][bgn][ed] = (d[len][bgn-1][ed] + c[len-1][bgn-1][ed-1])%MOD;
if (len%2 == 1){
d[len][ed][bgn] = d[len][bgn][ed];
c[len][ed][bgn] = c[len][bgn][ed];
}
else {
d[len][ed][bgn] = c[len][bgn][ed];
c[len][ed][bgn] = d[len][bgn][ed];
}
}
}
}
fprintf (fout,"%d",(c[n][cs][cf] + d[n][cs][cf])%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... |