結果

問題 No.133 カードゲーム
ユーザー youmeiyoumei
提出日時 2020-08-02 15:46:01
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 2 ms / 5,000 ms
コード長 863 bytes
コンパイル時間 1,768 ms
コンパイル使用メモリ 168,396 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-25 19:23:10
合計ジャッジ時間 2,788 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include<bits/stdc++.h>

#define _GLIBCXX_DEBUG
#define all(v) (v).begin(),(v).end()

using namespace std;

using ll=long long;
using pii=pair<int, int>;
using vi=vector<int>;
using vii=vector<vector<int>>;

const ll LINF=1LL<<60;
const int INF=1<<29;
const int MOD=1e9+7;

int main(){
    int N; cin >> N;
    vi a(N), b(N);
    for(auto &x : a) cin >> x;
    for(auto &x : b) cin >> x;
    vi ord1(N), ord2(N);
    for(int i=0; i<N; i++){
        ord1[i]=i;
        ord2[i]=i;
    }
    int cnt=0, win=0;
    do{
        do{
            cnt++;
            int k=0;
            for(int i=0; i<N; i++){
                if(a[ord1[i]] > b[ord2[i]]) k++;
            }
            if(k > N-k) win++;
        }while(next_permutation(all(ord2)));
    }while(next_permutation(all(ord1)));
    cout << fixed << setprecision(4) << (double)win/cnt << endl;
    return 0;
}
0