結果
問題 | No.133 カードゲーム |
ユーザー |
|
提出日時 | 2016-05-04 22:53:59 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 31 ms / 5,000 ms |
コード長 | 902 bytes |
コンパイル時間 | 805 ms |
コンパイル使用メモリ | 87,192 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-25 03:43:41 |
合計ジャッジ時間 | 2,217 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 19 |
ソースコード
#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; }