제출 #173228

#제출 시각아이디문제언어결과실행 시간메모리
173228Ruxandra985캥거루 (CEOI16_kangaroo)C++14
6 / 100
2 ms504 KiB
#include <cstdio>
#include <iostream>
#define MOD 1000000007
#define DIMN 2010
using namespace std;
long long dp[DIMN][DIMN];
int main()
{
    FILE *fin = stdin;
    FILE *fout = stdout;
    long long n , cs , cf , i , j , nr;
    fscanf (fin,"%lld%lld%lld",&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 + (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 + ( (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,"%lld",dp[n][1]);
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:12:12: warning: ignoring return value of 'int fscanf(FILE*, const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
     fscanf (fin,"%lld%lld%lld",&n,&cs,&cf);
     ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...