結果

問題 No.133 カードゲーム
ユーザー ああああ
提出日時 2023-01-12 17:25:42
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 925 bytes
コンパイル時間 2,144 ms
コンパイル使用メモリ 166,784 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-08-24 23:41:12
合計ジャッジ時間 2,753 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
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;

int main()
{
    int n; cin >> n;
    vector<int> a(n),b(n),order_a(n),order_b(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> b[i];
    rep(i,0,n){
        order_a[i] = i;
        order_b[i] = i;
    }
    double win=0,lose=0;
    do{
        do{
            int cnt = 0;
            rep(i,0,n) cnt += (a[order_a[i]]>b[order_b[i]]);
            if(cnt>n/2) win++;
            else lose++;
        }while(next_permutation(order_b.begin(),order_b.end()));
    }while(next_permutation(order_a.begin(),order_a.end()));
    cout << setprecision(20) << win/(win+lose) << endl;
}
0