結果

問題 No.133 カードゲーム
ユーザー 4094706840947068
提出日時 2024-01-09 11:29:33
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 4 ms / 5,000 ms
コード長 1,391 bytes
コンパイル時間 4,231 ms
コンパイル使用メモリ 230,236 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-09 11:29:39
合計ジャッジ時間 5,811 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 1 ms
6,676 KB
testcase_05 AC 1 ms
6,676 KB
testcase_06 AC 1 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 1 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 4 ms
6,676 KB
testcase_15 AC 2 ms
6,676 KB
testcase_16 AC 2 ms
6,676 KB
testcase_17 AC 2 ms
6,676 KB
testcase_18 AC 1 ms
6,676 KB
testcase_19 AC 1 ms
6,676 KB
testcase_20 AC 2 ms
6,676 KB
testcase_21 AC 1 ms
6,676 KB
testcase_22 AC 2 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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;
}
0