제출 #1264369

#제출 시각아이디문제언어결과실행 시간메모리
1264369duyanhloveav캥거루 (CEOI16_kangaroo)C++20
100 / 100
16 ms15944 KiB
#include <bits/stdc++.h>
using namespace std;

#define MASK(i) (1LL << (i))
#define BIT(x, i) (((x) >> (i)) & 1LL)

using ll = long long;

const int mxn = 9 + 1e6;
const int inf = 0x3f3f3f3f;
const ll lnf = 0x3f3f3f3f3f3f3f3f;

void _27augain(void) {
  int n, cs, cf;
  cin >> n >> cs >> cf;
  vector<vector<int>> dp(n + 2, vector<int>(n + 2));
  dp[0][0] = 1;
  const int mod = 7 + 1e9;
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= i; ++j) {
      if (i == cs || i == cf) {
        (dp[i][j] += dp[i - 1][j - 1] + dp[i - 1][j]) %= mod;
      } else {
        (dp[i][j] += 1LL * dp[i - 1][j - 1] * (j - (i > cs) - (i > cf)) % mod + 1LL * dp[i - 1][j + 1] * j % mod) %= mod;
      }
    }
  }
  cout << dp[n][1] << "\n";
}

int32_t main(void) {
#define task "27augain"
  cin.tie(0)->sync_with_stdio(0);
  for (string iext : {"in", "inp"}) {
    if (fopen((task "." + iext).c_str(), "r")) {
      freopen((task "." + iext).c_str(), "r", stdin);
      freopen(task ".out", "w", stdout);
    }
  }
  int testcase = 1;
  // cin >> testcase;
  while (testcase--) {
    _27augain();
  }
  return 0;
}

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

kangaroo.cpp: In function 'int32_t main()':
kangaroo.cpp:36:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   36 |       freopen((task "." + iext).c_str(), "r", stdin);
      |       ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
kangaroo.cpp:37:14: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   37 |       freopen(task ".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...