結果
問題 | No.173 カードゲーム(Medium) |
ユーザー | ttkkggww |
提出日時 | 2022-08-19 04:19:29 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 2,993 ms / 3,000 ms |
コード長 | 1,408 bytes |
コンパイル時間 | 5,474 ms |
コンパイル使用メモリ | 259,864 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-04-16 11:01:43 |
合計ジャッジ時間 | 38,671 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2,992 ms
5,248 KB |
testcase_01 | AC | 2,991 ms
5,376 KB |
testcase_02 | AC | 2,992 ms
5,376 KB |
testcase_03 | AC | 2,992 ms
5,376 KB |
testcase_04 | AC | 2,992 ms
5,376 KB |
testcase_05 | AC | 2,992 ms
5,376 KB |
testcase_06 | AC | 2,992 ms
5,376 KB |
testcase_07 | AC | 2,992 ms
5,376 KB |
testcase_08 | AC | 2,993 ms
5,376 KB |
testcase_09 | AC | 2,992 ms
5,376 KB |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/all> using namespace atcoder; using ll = long long; int n; double pa,pb; vector<int> A,B; chrono::time_point<chrono::system_clock> start; int getTime() { return chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now()-start).count(); } double rand01(){ return (double)rand()/RAND_MAX; } void solve(){ std::random_device seed_gen; std::default_random_engine engine(seed_gen()); std::uniform_int_distribution<> dist(0,232792560 ); sort(A.rbegin(),A.rend()); sort(B.rbegin(),B.rend()); double win = 0,game= 0; while(getTime()<2'990'000){ auto C = A,D = B; int Csum = 0,Dsum = 0; for(int i = 0;i<n;i++){ int Ccur,Dcur; if(rand01()<pa||C.size()==1){ Ccur = C.back(); C.pop_back(); }else{ int idx = dist(engine)%(C.size()-1); Ccur = C[idx]; C.erase(C.cbegin()+idx); } if(rand01()<pb||D.size()==1){ Dcur = D.back(); D.pop_back(); }else{ int idx = dist(engine)%(D.size()-1); Dcur = D[idx]; D.erase(D.cbegin()+idx); } if(Ccur>Dcur)Csum += Ccur+Dcur; else Dsum += Dcur+Ccur; } if(Csum>Dsum)win++; game++; } printf("%.10lf\n",win/game); } signed main(){start = chrono::system_clock::now(); cin.tie(nullptr); ios::sync_with_stdio(false); cin >> n >> pa >> pb; A = B = vector<int>(n); for(auto &i:A)cin >> i; for(auto &i:B)cin >> i; solve(); }