제출 #633977

#제출 시각아이디문제언어결과실행 시간메모리
633977Denisov캥거루 (CEOI16_kangaroo)C++14
0 / 100
0 ms212 KiB
#include <bits/stdc++.h> #include <ext/rope> #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> //#pragma GCC optimize("Ofast") //#pragma GCC optimize("unroll-loops") //#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native") //#define int long long #define pb push_back #define x first #define y second #define mk(a,b) make_pair(a,b) #define rr return 0 #define sqr(a) ((a)*(a)) #define all(a) (a).begin(), (a).end() #define sz(a) (int)(a).size() #undef M_PI #define M_PI 3.14159265358979323846264338327950288419 using namespace std; using namespace __gnu_cxx; using namespace __gnu_pbds; using ll = long long; using ull = unsigned long long; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using big = __int128; template<class value, class cmp = less<value> > using ordered_set = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>; template<class value, class cmp = less_equal<value> > using ordered_multiset = tree<value, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>; template<class key, class value, class cmp = less<key> > using ordered_map = tree<key, value, cmp, rb_tree_tag, tree_order_statistics_node_update>; /// find_by_order() /// order_of_key() mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); template<typename T = int> inline T randll(T l = INT_MIN, T r = INT_MAX) { return uniform_int_distribution<T>(l, r)(rng); } inline ld randld(ld l = INT_MIN, ld r = INT_MAX) { return uniform_real_distribution<ld>(l, r)(rng); } const int INF = 2e9 + 11; const int MOD = 1e9 + 7; /// think const ll LINF = ll(2e18) + 11; const int dx[] = {0, 0, 1, -1}, dy[] = {1, -1, 0, 0}; template<class T> bool umin (T &a, T b) {return a > b ? (a = b, true) : false; } template<class T> bool umax (T &a, T b) {return a < b ? (a = b, true) : false; } #ifdef LOCAL #include "debug.h" #else #define debug(...) 42 #endif struct mint { int val; mint () : val(0) {} mint (int x) { if (-MOD <= x && x < MOD) { val = x; } else { val = x % MOD; } if (val < 0) val += MOD; } mint (ll x) { if (-MOD <= x && x < MOD) { val = x; } else { val = x % MOD; } if (val < 0) val += MOD; } mint (const mint& x) : val(x.val) {} constexpr mint& operator = (const mint& x) { val = x.val; return *this; } inline mint& operator += (const mint &x) { val += x.val; if (val >= MOD) { val -= MOD; } return *this; } inline mint& operator -= (const mint &x) { val -= x.val; if (val < 0) { val += MOD; } return *this; } inline mint operator - () const { mint tmp(*this); if (tmp.val) tmp.val = MOD - tmp.val; return tmp; } inline mint operator + (const mint &x) const { return mint(*this) += x; } inline mint operator - (const mint &x) const { return mint(*this) -= x; } inline mint& operator *= (const mint &x) { val = ((ll)val * x.val) % MOD; return *this; } inline mint operator * (const mint &x) const { return mint(*this) *= x; } inline mint binpow (int n) const { mint res = 1, tmp = *this; for (; n; n >>= 1) { if (n & 1) { res *= tmp; } tmp *= tmp; } return res; } inline mint inverse () const { return binpow(MOD - 2); } inline mint& operator /= (const mint &x) { return *this *= x.inverse(); } inline mint operator / (const mint &x) { return mint(*this) *= x.inverse(); } friend ostream& operator << (ostream &os, const mint &x) { os << x.val; return os; } friend istream& operator >> (istream &is, mint &x) { is >> x.val; return is; } inline bool operator == (const mint &x) const { return val == x.val; } inline bool operator != (const mint &x) const { return val != x.val; } inline bool operator < (const mint &x) const { return val < x.val; } inline bool operator > (const mint &x) const { return val > x.val; } friend string to_string (const mint &x) { return to_string(x.val); } }; vector <mint> f = {1}, fi = {1}; inline mint fact (int n) { f.reserve(n + 1); while (sz(f) <= n) { f.emplace_back(f.back() * sz(f)); } return f[n]; } inline mint inv_fact (int n) { /// think if (sz(fi) <= n) { fi.resize(n + 1, 0); mint val = mint(1) / fact(n); for (int i = n; fi[i] == 0; i--) { fi[i] = val; val *= i; } } return fi[n]; } inline mint A (int n, int k) { if (k < 0 || k > n) return 0; return fact(n) * inv_fact(n - k); } inline mint C (int n, int k) { if (k < 0 || k > n) return 0; return A(n, k) * inv_fact(k); } inline void test_case () { int n, a, b; cin >> n >> a >> b; vector <vector <mint> > dp(n + 1, vector <mint> (n + 1)); dp[1][1] = 1; for (int i = 1; i < n; i++) { for (int j = 0; j <= i; j++) { if (i + 1 == a || i + 1 == b) { dp[i + 1][j] += dp[i][j]; if (j + 1 <= n) { dp[i + 1][j + 1] += dp[i][j]; } } else { if (j + 1 <= n) { dp[i + 1][j + 1] += dp[i][j] * (j + 1 - (i + 1 < a) - (i + 1 < b)); } if (j - 1 >= 0) { dp[i + 1][j - 1] += dp[i][j] * (j - 1); } } } } cout << dp[n][1] << '\n'; } main() { ios::sync_with_stdio(0); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); int t = 1; // cin >> t; for (int test = 1; test <= t; test++) { test_case(); } }

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

kangaroo.cpp:252:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
  252 | main()
      | ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...