結果

問題 No.133 カードゲーム
ユーザー haraduka_haraduka_
提出日時 2015-01-22 23:52:12
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,552 bytes
コンパイル時間 2,117 ms
コンパイル使用メモリ 89,252 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-07 09:08:55
合計ジャッジ時間 1,732 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<iostream>
#include<string>
#include<map>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<functional>
#include<utility>
#include<iterator>
#include<algorithm>
#include<sstream>
#include<fstream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<ctime>
#include<cstring>
#include<iomanip>
using namespace std;
#define len(val) static_cast<int>(val.size())
#define rep(i, N) for(int i=0; i<N; i++)
typedef long long ll;
typedef pair<int, int> P;

int n;
int a[4], b[4];
int hikiwake = 0;
int dfs(int ba, int bb, int cnt){
    int test = 0;
    for(int i=0; i<n; i++){
        if(ba & (1<<i)) test++;
    }
    if(test == n){
        if(n%2 == 0 && cnt*2 == n){
            hikiwake++;
            return 0;
        }else if(cnt*2 > n){
            return 1;
        }else{
            return 0;
        }
    }
    int res = 0;
    for(int i=0; i<n; i++){
        if(!(ba & (1<<i))){
            for(int j=0; j<n; j++){
                if(!(bb & (1<<j))){
                    if(a[i] > b[j]){
                        res += dfs(ba|(1<<i), bb|(1<<j), cnt+1);
                    }else{
                        res += dfs(ba|(1<<i), bb|(1<<j), cnt);
                    }
                }
            }
        }
    }
    return res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    cin >> n;
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> b[i];
    int t = 1;
    for(int i=1; i<=n; i++) t*=i;
    cout << (double)dfs(0, 0, 0)/t/t<< endl;
}
0