結果

問題 No.133 カードゲーム
ユーザー BantakoBantako
提出日時 2017-08-23 23:52:01
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 757 bytes
コンパイル時間 1,650 ms
コンパイル使用メモリ 171,984 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-06-25 03:49:30
合計ジャッジ時間 2,438 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 19
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:10:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   10 | main(){
      | ^~~~

ソースコード

diff #

#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
int fact(int n){
    if(n == 1)return 1;
    return n*fact(n-1);
}
main(){
    int N;
    cin >> N;
    vector<int>A,B;
    for(int i = 0;i < N;i++){int a;cin >> a;A.push_back(a);}
    for(int i = 0;i < N;i++){int a;cin >> a;B.push_back(a);}
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    int v = 0;
    do{
        do{
            int cnt = 0;
            for(int i = 0;i < N;i++){
                if(A[i] > B[i])cnt++;
                else cnt--;
            }
            if(cnt > 0)v++;
        }while(next_permutation(B.begin(),B.end()));
    }while(next_permutation(A.begin(),A.end()));
    cout << 1. * v / (fact(N)*fact(N)) << endl;;
}
0