제출 #1323681

#제출 시각아이디문제언어결과실행 시간메모리
1323681ziad3ssam10캥거루 (CEOI16_kangaroo)C++20
100 / 100
57 ms32476 KiB
#include <bits/stdc++.h> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace std; using namespace __gnu_pbds; template<typename T> using orderedset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #define int long long #define ll long long #define ld long double #define endl '\n' #define wady \ ios_base::sync_with_stdio(0); \ cin.tie(0); \ cout.tie(0); void files() { #ifndef ONLINE_JUDGE freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); #endif } const int mod = 1e9 + 7; int add(int a,int b) { return (a + b) % mod; } int mul(int a,int b) { return (a * b) % mod; } const int N = 2000 + 20; int n; int dp[N][N]; int st, en; int rec(int idx,int comp) { if (idx > n)return comp == 1; int &ret = dp[idx][comp]; if (~ret)return ret; ret = 0; if (idx == st or idx == en) { ret = add(rec(idx + 1, comp + 1), ret); if (comp) ret = add(ret, rec(idx + 1, comp)); } else { ret = add(ret, mul(rec(idx + 1, comp + 1), (comp + 1) - (idx > st) - (idx > en))); if (comp >= 2)ret = add(ret, mul(rec(idx + 1, comp - 1), comp - 1)); } return ret; } void solve(int tc) { cin >> n; cin >> st >> en; memset(dp, -1, sizeof dp); cout << rec(1, 0) << endl; } signed main() { wady // files(); int t = 1; // cin >> t; int tc = 1; while (t--) solve(tc++); }

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

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