제출 #492876

#제출 시각아이디문제언어결과실행 시간메모리
492876czhang2718캥거루 (CEOI16_kangaroo)C++17
0 / 100
2 ms332 KiB
#include "bits/stdc++.h" using namespace std; const int MOD=1e9+7; int n, s, e; int dp[2001], dp2[2001]; int mult(int a, int b){ return ((long long )a*b)%MOD; } int add(int &a, int b){ a+=b; if(a>=MOD) a-=MOD; return a; } int main(){ cin.tie(0)->sync_with_stdio(0); freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout); cin >> n >> s >> e; dp[0]=1; for(int i=1; i<=n; i++){ for(int j=0; j<i; j++){ if(!dp[j]) continue; if(i==s || i==e){ add(dp2[j+1], dp[j]); if(j) add(dp2[j], dp[j]); continue; } add(dp2[j+1], mult(dp[j], (j+1-(i>s)-(i>e)))); if(j>=2) dp2[j-1]+=mult(dp[j], j-1); } for(int j=0; j<=i; j++){ dp[j]=dp2[j]; dp2[j]=0; } } cout << dp[1]; }

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

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:20:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   20 |   freopen("kangaroo.in", "r", stdin);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:21:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   21 |   freopen("kangaroo.out", "w", stdout);
      |   ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...