結果
| 問題 |
No.108 トリプルカードコンプ
|
| コンテスト | |
| ユーザー |
kumakumaaaaa
|
| 提出日時 | 2021-02-18 09:55:32 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,194 bytes |
| コンパイル時間 | 1,837 ms |
| コンパイル使用メモリ | 177,624 KB |
| 実行使用メモリ | 23,168 KB |
| 最終ジャッジ日時 | 2024-09-14 17:13:58 |
| 合計ジャッジ時間 | 3,209 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 7 WA * 13 |
ソースコード
#include <bits/stdc++.h>
// #include <atcoder/modint>
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define INF 2000000000000000000
#define ll long long
#define ld long double
#define pll pair<ll, ll>
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
ll N;
map<vector<ll>, ll> mp;
ld bfs(ll x, ll y, ll z) {
if (mp.find({x, y, z}) != mp.end()) {
return mp[{x, y, z}];
}
if (z == N) {
return 0;
}
ld res = 0;
ld mul = (N - z) / (ld)(N);
if (x + y + z != N) {
res += (bfs(x + 1, y, z) * (N - (x + y + z)) / (ld)(N));
}
if (x != 0) {
res += ((bfs(x - 1, y + 1, z)) * (x) / (ld)(N));
}
if (y != 0) {
res += ((bfs(x, y - 1, z + 1)) * (y) / (ld)(N));
}
mp[{x, y, z}] = (res + 1) / mul;
return (res + 1) / mul;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
cin >> N;
vector<ll> A(N);
vector<ll> num(4, 0);
for (ll i = 0; i < N; ++i) {
cin >> A.at(i);
num.at(min(3ll, A.at(i))) += 1;
}
cout << bfs(num.at(1), num.at(2), num.at(3)) << "\n";
}
kumakumaaaaa