結果
| 問題 |
No.133 カードゲーム
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-01-09 11:29:33 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 5,000 ms |
| コード長 | 1,391 bytes |
| コンパイル時間 | 4,312 ms |
| コンパイル使用メモリ | 230,860 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-27 19:49:12 |
| 合計ジャッジ時間 | 4,832 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 19 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T &a, T b) { return ((a>b) ? (a = b, true) : (false));}
#define rep(i,s,n) for(long long i=s;i<(long long)(n);i++)
const long long inf = 1LL<<60;
typedef long long ll;
#define cmp [](pair<ll,ll> a, pair<ll,ll> b){return a.second<b.second;} //pairのsecondでソートsort(p.begin(),p.end(),cmp)
typedef pair<long long, long long> P;
typedef pair<ll, pair<ll,ll> > PP;
#define rll ll,vector<ll>,greater<ll>
const long double pi = 3.14159265358979;
typedef unsigned long long ull;
using mint = modint998244353;
int main()
{
ll n; cin >> n;
vector<ll> a(n), b(n);
rep(i,0,n) cin >> a[i];
rep(i,0,n) cin >> b[i];
long double all = 0, win = 0;
vector<ll> order_a(n), order_b(n);
rep(i,0,n) {order_a[i] = i; order_b[i] = i;}
do {
do {
ll cn_a = 0, cn_b = 0;
rep(i,0,n) cn_a += (a[order_a[i]] > b[order_b[i]]);
rep(i,0,n) cn_b += (b[order_b[i]] > a[order_a[i]]);
if(cn_a > cn_b) win++;
all++;
} while(next_permutation(order_b.begin(), order_b.end()));
}while(next_permutation(order_a.begin(), order_a.end()));
cout << setprecision(20) << win/all << endl;
}