結果

問題 No.133 カードゲーム
ユーザー naribownaribow
提出日時 2020-08-08 10:15:43
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 3 ms / 5,000 ms
コード長 1,284 bytes
コンパイル時間 1,740 ms
コンパイル使用メモリ 172,776 KB
実行使用メモリ 6,548 KB
最終ジャッジ日時 2024-04-08 15:09:33
合計ジャッジ時間 2,680 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int MAX_N = 362881;

// 重複があってもすべての順列を列挙する
// next_permutationは辞書順で次の順列を生成する
int perm[MAX_N];
int perm2[MAX_N];
int num = 0;
int all = 0;

void permutation2(int n) {
    do {
        // permに対する操作
        int win=0;
        rep(i, n){
            if(perm[i] > perm2[i]) win++;
        }
        if(win > (n/2)) num++;
        all++;
    } while (next_permutation(perm2, perm2 + n));
    return;
    
}

void permutation(int n) {
    do {
        // permに対する操作
        permutation2(n);
    } while (next_permutation(perm, perm + n));
    return;
    
}

int main(){
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    rep(i, n) cin >> a.at(i);
    rep(i, n) cin >> b.at(i);
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    rep(i, n) perm[i] = a.at(i);
    rep(i, n) perm2[i] = b.at(i);
    permutation(n);
    ldouble p = (ldouble) num / (ldouble) all;
    cout << p << endl;
}
0