제출 #318178

#제출 시각아이디문제언어결과실행 시간메모리
318178a14789654캥거루 (CEOI16_kangaroo)C++17
0 / 100
1 ms384 KiB
///https://oj.uz/problem/view/CEOI16_kangaroo #include <bits/stdc++.h> using namespace std; const int MAXN = 2007, MOD = 1e9 + 7; int cs, cf, n, f[MAXN][MAXN]; void add(int &a, int b) { a += b; if (a >= MOD) a -= MOD; } int main() { if (fopen("tst.inp", "r")) { freopen("tst.inp", "r", stdin); freopen("tst.out", "w", stdout); } ios_base::sync_with_stdio(0); cin.tie(0), cout.tie(0); cin >> n >> cs >> cf; if (cs > cf) swap(cs, cf); f[0][0] = 1; for (int i = 0; i <= n; ++i) for (int j = 0; j <= n; ++j) if (f[i][j] != - 1) { if (i != cs && i != cf) { if (i < n && j) add(f[i + 1][j - 1], 1LL * f[i][j] * j * (j - 1) % MOD); if (i < n && j < n) add(f[i + 1][j + 1], f[i][j]); if (i > cs && i < n && j) add(f[i + 1][j - 1], 1LL * f[i][j] * j % MOD); if (i > cf && i < n && j) add(f[i + 1][j - 1], 1LL * f[i][j] * j % MOD); } else { add(f[i + 1][j], f[i][j]); if (j) add(f[i + 1][j - 1], 1LL * f[i][j] * j % MOD); } } cout << f[n][0]; return 0; }

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

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