結果

問題 No.133 カードゲーム
ユーザー cro68831269
提出日時 2022-05-19 18:23:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,027 bytes
コンパイル時間 2,052 ms
コンパイル使用メモリ 196,576 KB
最終ジャッジ日時 2025-01-29 09:31:34
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<class T> using V = std::vector<T>;
#define REP(i, n) for (ll i=(ll)0; i<(ll)(n); i++)
#define REPS(i, s, n) for (ll i=(ll)(s); i<(ll)(n); i++)
#define RREP(i, n) for (ll i=(ll)(n); i>(ll)0; i--)
#define RREPS(i, s, n) for (ll i=(ll)(n); i>(ll)(s); i--)
#define ALL(c) std::begin((c)), std::end((c))
struct io {io() {cin.tie(0); ios::sync_with_stdio(0);} } caller;

int main(){
    int n;
    cin >> n;

    V<int> a(n), b(n);
    REP (i, n) cin >> a[i];
    REP (i, n) cin >> b[i];

    V<int> order_a(n), order_b(n);
    iota(ALL(order_a), 0), iota(ALL(order_b), 0);

    int win = 0, cnt = 0;
    do{
        do{
            int pa = 0;
            REP (i, n){
                if (a[order_a[i]] > b[order_b[i]]) pa++;
            }

            cnt++;
            if (2 * pa > n) win++;

        }while (next_permutation(ALL(order_a)));
    }while (next_permutation(ALL(order_b)));

    cout << (long double)win / cnt << endl;
    
    return 0;
}
0