# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
173224 | 2020-01-03T15:36:06 Z | Ruxandra985 | Kangaroo (CEOI16_kangaroo) | C++14 | 2 ms | 376 KB |
#include <cstdio> #include <iostream> #define MOD 1000000007 #define DIMN 2010 using namespace std; int dp[DIMN][DIMN]; int main() { FILE *fin = stdin; FILE *fout = stdout; int n , cs , cf , i , j , nr; fscanf (fin,"%d%d%d",&n,&cs,&cf); if (cs > cf) swap(cs,cf); dp[0][0] = 1; for (i=1;i<=n;i++){ //if (i == 4) // printf ("a"); if (i == cs || i == cf){ /// pe i il poti adauga doar intr o pozitie for (j = 1 ; j <= i ; j ++) dp[i][j] = (dp[i-1][j-1] + dp[i-1][j] * (j - (i == cf) + (i == cf && j == 1)))%MOD; } else { for (j = 1 ; j <= i ; j ++){ nr = ( (long long)j * (j+1) )%MOD; if (i < cf && i > cs) /// exista UN lant care incepe cu cs, pe ala nu trb sa il cuplam nr = (j + ((long long)j * (j-1))%MOD)%MOD; else if (i > cf){ /// exista UN lant care se termina cu cf, la inceputul astuia CLAR nu pui nr = (1 + ( (long long)(j - 1) * (j - 2) / 2)%MOD )%MOD; } nr = (nr + MOD) % MOD; dp[i][j] = ( dp[i][j] + ( dp[i-1][j+1] * nr )%MOD )%MOD; dp[i][j] = ( dp[i][j] + dp[i-1][j-1] )%MOD; /// pui i singur } } } fprintf (fout,"%d",dp[n][1]); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 1 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 1 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 376 KB | Output is correct |
2 | Correct | 2 ms | 376 KB | Output is correct |
3 | Incorrect | 1 ms | 376 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |