結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
printf_naoki
|
| 提出日時 | 2020-08-24 13:49:25 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 2,855 bytes |
| コンパイル時間 | 1,625 ms |
| コンパイル使用メモリ | 172,636 KB |
| 実行使用メモリ | 6,820 KB |
| 最終ジャッジ日時 | 2024-11-06 10:18:41 |
| 合計ジャッジ時間 | 2,524 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
// エイリアス
using ll = long signed long;
using ull = long unsigned long;
using ld = long double;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
// 汎用マクロ
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define FOREACH(i,q) for (auto &i : q)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
#define SZ(x) ((int)(x).size())
template <class T>inline bool chmin(T &a, const T b) {if (a > b) { a = b; return true;} return false;}
template <class T>inline bool chmax(T &a, const T b) {if (a < b) { a = b; return true;} return false;}
template <class T>inline void line_out(const vector<T> vec) {int n = SZ(vec); rep(i, n) { cout << vec[i]; if(i < n-1) cout << " ";}cout << endl;}
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 28;
const ll INF64 = 1ll << 60;
const int mod = 1000000007;
//const int mod = 998244353;
//const int mod = 100000;
struct mint
{
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint operator-() const { return mint(-x); }
mint &operator+=(const mint a)
{
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a)
{
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a)
{
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const
{
mint res(*this);
return res += a;
}
mint operator-(const mint a) const
{
mint res(*this);
return res -= a;
}
mint &operator++()
{
if ((x += 1) >= mod)
x -= mod;
return *this;
}
mint &operator--()
{
if ((x += mod - 1) >= mod)
x -= mod;
return *this;
}
mint operator*(const mint a) const
{
mint res(*this);
return res *= a;
}
mint pow(ll t) const
{
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const
{
return pow(mod - 2);
}
mint &operator/=(const mint a)
{
return (*this) *= a.inv();
}
mint operator/(const mint a) const
{
mint res(*this);
return res /= a;
}
};
int main()
{
int n; cin >> n;
vector<int> a(n), b(n), idx(n);
rep(i, n) cin >> a[i];
rep(i, n) cin >> b[i];
sort(ALL(a));
sort(ALL(b));
int win = 0;
int sum = 0;
do {
do{
int count = 0;
rep(i, n) if(a[i] > b[i]) ++count;
if(count > n/2) ++win;
++sum;
} while(next_permutation(ALL(a)));
} while(next_permutation(ALL(b)));
double ans = (double)win / sum;
printf("%0.12f\n", ans);
}
printf_naoki