結果

問題 No.133 カードゲーム
ユーザー sumeragifseieisumeragifseiei
提出日時 2018-08-11 10:38:38
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 980 bytes
コンパイル時間 732 ms
コンパイル使用メモリ 56,232 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-24 13:46:15
合計ジャッジ時間 1,805 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <cstring>
using namespace std;
typedef long long ll;
ll n, a[6], b[6], c[6], d[6];
double res;
bool e[6], f[6];

void dfs(ll x){
    if (x == n * 2) {
        ll A = 0, B = 0;
        for (ll i = 0; i < n; i++) {
            if (c[i] > d[i]) A++;
            if (c[i] < d[i]) B++;
        }
        if (A > B) res++;
    } else if (x < n) {
        for (ll i = 0; i < n; i++) {
            if (e[i]) continue;
            c[x] = a[i];
            e[i] = true;
            dfs(x + 1);
            e[i] = false;
        }
    } else {
        for (ll i = 0; i < n; i++) {
            if (f[i]) continue;
            d[x - n] = b[i];
            f[i] = true;
            dfs(x + 1);
            f[i] = false;
        }
    }
}

int main(void){
    // Your code here!
    cin >> n;
    for (ll i = 0; i < n; i++) cin >> a[i];
    for (ll i = 0; i < n; i++) cin >> b[i];
    dfs(0);
    for (ll i = 2; i <= n; i++) res /= i * i;
    cout << res << endl;
}
0