結果
問題 | No.1688 Veterinarian |
ユーザー | stoq |
提出日時 | 2021-09-24 21:50:20 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 109 ms / 3,000 ms |
コード長 | 4,272 bytes |
コンパイル時間 | 1,802 ms |
コンパイル使用メモリ | 205,740 KB |
実行使用メモリ | 162,304 KB |
最終ジャッジ日時 | 2024-07-05 10:25:45 |
合計ジャッジ時間 | 4,328 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 98 ms
162,304 KB |
testcase_01 | AC | 97 ms
162,176 KB |
testcase_02 | AC | 96 ms
162,176 KB |
testcase_03 | AC | 97 ms
162,176 KB |
testcase_04 | AC | 97 ms
162,176 KB |
testcase_05 | AC | 98 ms
162,176 KB |
testcase_06 | AC | 98 ms
162,176 KB |
testcase_07 | AC | 96 ms
162,304 KB |
testcase_08 | AC | 109 ms
162,176 KB |
testcase_09 | AC | 108 ms
162,176 KB |
testcase_10 | AC | 100 ms
162,176 KB |
testcase_11 | AC | 98 ms
162,176 KB |
testcase_12 | AC | 97 ms
162,176 KB |
testcase_13 | AC | 97 ms
162,048 KB |
testcase_14 | AC | 97 ms
162,176 KB |
testcase_15 | AC | 102 ms
162,176 KB |
testcase_16 | AC | 97 ms
162,304 KB |
ソースコード
#define MOD_TYPE 2 #pragma region Macros #include <bits/stdc++.h> using namespace std; #if 1 #pragma GCC target("avx2") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #endif #if 0 #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tag_and_trait.hpp> #include <ext/pb_ds/tree_policy.hpp> #include <ext/rope> using namespace __gnu_pbds; using namespace __gnu_cxx; template <typename T> using extset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; #endif #if 0 #include <boost/multiprecision/cpp_dec_float.hpp> #include <boost/multiprecision/cpp_int.hpp> using Int = boost::multiprecision::cpp_int; using lld = boost::multiprecision::cpp_dec_float_100; #endif using ll = long long int; using ld = long double; using pii = pair<int, int>; using pll = pair<ll, ll>; using pld = pair<ld, ld>; template <typename T> using smaller_queue = priority_queue<T, vector<T>, greater<T>>; constexpr ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353); constexpr int INF = (int)1e9 + 10; constexpr ll LINF = (ll)4e18; constexpr ld PI = acos(-1.0); constexpr ld EPS = 1e-7; constexpr int Dx[] = {0, 0, -1, 1, -1, 1, -1, 1, 0}; constexpr int Dy[] = {1, -1, 0, 0, -1, -1, 1, 1, 0}; #define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i) #define rep(i, n) REP(i, 0, n) #define REPI(i, m, n) for (int i = m; i < (int)(n); ++i) #define repi(i, n) REPI(i, 0, n) #define MP make_pair #define MT make_tuple #define YES(n) cout << ((n) ? "YES" : "NO") << "\n" #define Yes(n) cout << ((n) ? "Yes" : "No") << "\n" #define possible(n) cout << ((n) ? "possible" : "impossible") << "\n" #define Possible(n) cout << ((n) ? "Possible" : "Impossible") << "\n" #define all(v) v.begin(), v.end() #define NP(v) next_permutation(all(v)) #define dbg(x) cerr << #x << ":" << x << "\n"; #define UNIQUE(v) v.erase(unique(all(v)), v.end()) struct io_init { io_init() { cin.tie(0); ios::sync_with_stdio(false); cout << setprecision(30) << setiosflags(ios::fixed); }; } io_init; template <typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; } template <typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; } inline ll CEIL(ll a, ll b) { return (a + b - 1) / b; } template <typename A, size_t N, typename T> inline void Fill(A (&array)[N], const T &val) { fill((T *)array, (T *)(array + N), val); } template <typename T> vector<T> compress(vector<T> &v) { vector<T> val = v; sort(all(val)), val.erase(unique(all(val)), val.end()); for (auto &&vi : v) vi = lower_bound(all(val), vi) - val.begin(); return val; } template <typename T, typename U> constexpr istream &operator>>(istream &is, pair<T, U> &p) noexcept { is >> p.first >> p.second; return is; } template <typename T, typename U> constexpr ostream &operator<<(ostream &os, pair<T, U> &p) noexcept { os << p.first << " " << p.second; return os; } random_device seed_gen; mt19937_64 engine(seed_gen()); #pragma endregion // -------------------------------------- array<double, 3> dp[51][51][51][51]; inline double C2(ld n) { return n * (n - 1) / 2; } void add(array<double, 3> &A, array<double, 3> B) { rep(i, 3) A[i] += B[i]; } array<double, 3> mul(array<double, 3> A, double t) { rep(i, 3) A[i] *= t; return A; } array<double, 3> f(int a, int b, int c, int n) { if (n == 0) return {0, 0, 0}; if (dp[a][b][c][n][0] >= 0) return dp[a][b][c][n]; array<double, 3> res = {0, 0, 0}; if (a >= 2) { array<double, 3> tmp = f(a - 1, b, c, n - 1); tmp[0] += 1.0; add(res, mul(tmp, C2(a) / C2(a + b + c))); } if (b >= 2) { array<double, 3> tmp = f(a, b - 1, c, n - 1); tmp[1] += 1.0; add(res, mul(tmp, C2(b) / C2(a + b + c))); } if (c >= 2) { array<double, 3> tmp = f(a, b, c - 1, n - 1); tmp[2] += 1.0; add(res, mul(tmp, C2(c) / C2(a + b + c))); } add(res, mul(f(a, b, c, n - 1), (1.0 - (C2(a) + C2(b) + C2(c)) / C2(a + b + c)))); return dp[a][b][c][n] = res; } void solve() { array<double, 3> tmp = {-1, -1, -1}; Fill(dp, tmp); int a, b, c, n; cin >> a >> b >> c >> n; auto ans = f(a, b, c, n); rep(i, 3) cout << ans[i] << (i == 3 - 1 ? "\n" : " "); } int main() { solve(); }