제출 #685021

#제출 시각아이디문제언어결과실행 시간메모리
685021NeroZein캥거루 (CEOI16_kangaroo)C++14
0 / 100
2082 ms596 KiB
/* * author: NeroZein * created: 23.01.2023 08:16:46 */ #include <bits/stdc++.h> using namespace std; const int md = 1e9+7; inline int add(int a, int b){ a += b; if(a >= md){ a -= md; } return a; } inline int mul(int a, int b){ return (int)((long long) a * b % md); } signed main(){ freopen("kangaroo.in", "r", stdin); freopen("kangaroo.out", "w", stdout); ios::sync_with_stdio(false); cin.tie(nullptr); int n, cs, cf; cin >> n >> cs >> cf; vector<int> dp(n); dp[1] = 1; for (int i = 2; i <= n; ++i){ vector<int> pd(n); for (int j = 1; j <= n; ++j){ //endpoint either if(i == cs || i == cf){ //alone or to the left or right to existing set pd[j] = add(dp[j-1], dp[j]); } else{ //merge two sets or start a new one pd[j] = add(mul(j, dp[j+1]), mul(j - (i > cs) - (i > cf), dp[j-1])); } } swap(dp, pd); } cout << dp[1]; }

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

kangaroo.cpp: In function 'int main()':
kangaroo.cpp:23:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   23 |  freopen("kangaroo.in", "r", stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:24:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   24 |  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...