結果

問題 No.133 カードゲーム
ユーザー satanicsatanic
提出日時 2016-05-04 22:53:59
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 29 ms / 5,000 ms
コード長 902 bytes
コンパイル時間 2,336 ms
コンパイル使用メモリ 84,384 KB
実行使用メモリ 4,380 KB
最終ジャッジ日時 2023-09-07 09:25:46
合計ジャッジ時間 2,052 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <random>
#include <vector>

constexpr int battleNum = 100000;

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    
    std::random_device rnd;
    std::mt19937 mt(rnd());
    
    int n;
    std::cin >> n;
    std::vector<int> a(n), b(n);
    for(auto& it : a){
        std::cin >> it;
    }
    for(auto& it : b){
        std::cin >> it;
    }
    int cnt=0;
    for(int i=0; i<battleNum; ++i){
        int winCnt=0;
        std::vector<int> tmpA(a), tmpB(b);
        for(int j=n; j>=1; --j){
            int tmpAN = mt()%j;
            int tmpBN = mt()%j;
            if(tmpA[tmpAN]>tmpB[tmpBN]) ++winCnt;
            if(tmpA[tmpAN]<tmpB[tmpBN]) --winCnt;
            tmpA.erase(tmpA.begin()+tmpAN);
            tmpB.erase(tmpB.begin()+tmpBN);
        }
        if(winCnt>0) ++cnt;
    }
    std::cout << 1.0*cnt/battleNum << "\n";
    return 0;
}
0