제출 #1220911

#제출 시각아이디문제언어결과실행 시간메모리
1220911QuocSenseiKangaroo (CEOI16_kangaroo)C++20
100 / 100
45 ms31816 KiB
#include <bits/stdc++.h> #define ll long long #define el cout << '\n' using namespace std; const int maxn = 2e3; const int MOD = 1e9 + 7; int n, s, t; ll dp[maxn + 10][maxn + 10]; void add(ll &a, ll b) { b %= MOD; a += b; if (a >= MOD) a -= MOD; } int main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); if (fopen("KANGAROO.INP", "r")) { freopen("KANGAROO.INP", "r", stdin); freopen("KANGAROO.OUT", "w", stdout); } cin >> n >> s >> t; dp[0][0] = 1; for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) { if (i == s) { add(dp[i][j], dp[i - 1][j - 1]); if (i > t && i < n) add(dp[i][j], (j - 1) * dp[i - 1][j]); else if (i > t) add(dp[i][j], dp[i - 1][j]); else add(dp[i][j], j * dp[i - 1][j]); } else if (i == t) { add(dp[i][j], dp[i - 1][j - 1]); if (i > s && i < n) add(dp[i][j], (j - 1) * dp[i - 1][j]); else if (i > s) add(dp[i][j], dp[i - 1][j]); else add(dp[i][j], j * dp[i - 1][j]); } else { add(dp[i][j], dp[i - 1][j - 1]); if (i > max(s, t) && i < n) add(dp[i][j], j * (j - 1) * dp[i - 1][j + 1]); else if (i > max(s, t)) add(dp[i][j], dp[i - 1][j + 1]); else if (i > min(s, t)) add(dp[i][j], j * j * dp[i - 1][j + 1]); else add(dp[i][j], j * (j + 1) * dp[i - 1][j + 1]); } } // for (int i = 1; i <= n; i++) // { // for (int j = 1; j <= n; j++) // cout << dp[i][j] << ' '; // el; // } cout << dp[n][1]; }

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

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