結果

問題 No.133 カードゲーム
ユーザー Tttt YayTttt Yay
提出日時 2020-10-26 23:22:45
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 1,088 bytes
コンパイル時間 1,771 ms
コンパイル使用メモリ 173,144 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-29 03:00:48
合計ジャッジ時間 3,164 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,376 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>
//#include <atcoder/all>
#define rep(i, n) for (int i = 0; i < (n); i++)
using ll = long long;
using namespace std;
//using namespace atcoder;
const int mod = 1e7+7;
const int INF =1e9+1;
int n;
vector<int> a,b;
vector<bool> flag1,flag2;
int win=0, match=0;
void dfs(vector<int> x,vector<int> y){
    if(x.size()==n){
        match++;
        int tmp1=0,tmp2=0;
        rep(i,n){
            if(x[i]>y[i])tmp1++;
            else if(x[i]<y[i])tmp2++;
        }
        if(tmp1>tmp2)win++;
        return ;
    }
    for(int i=0;i<n;i++){
        if(flag1[i]==1)continue;
        x.push_back(a[i]);flag1[i]=1;
        rep(j,n){
            if(flag2[j]==1)continue;
            y.push_back(b[j]);flag2[j]=1;
            dfs(x,y);
            y.pop_back();flag2[j]=0;
        }
        x.pop_back(); flag1[i]=0;
    }
}
 
 
int main() {
    cin>>n;
    a=b=vector<int> (n);
    flag1=flag2=vector<bool>(n,0);
    rep(i,n)cin>>a[i];
    rep(i,n)cin>>b[i];
    dfs(vector<int>(0),vector<int>(0));
    cout<<fixed<<setprecision(15);
    cout<<(double)win/match<<endl;
}
0