結果
問題 | No.173 カードゲーム(Medium) |
ユーザー | kei |
提出日時 | 2018-09-09 01:49:40 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 412 ms / 3,000 ms |
コード長 | 2,480 bytes |
コンパイル時間 | 1,840 ms |
コンパイル使用メモリ | 175,148 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-06-01 10:22:07 |
合計ジャッジ時間 | 5,177 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
6,816 KB |
testcase_01 | AC | 73 ms
6,944 KB |
testcase_02 | AC | 362 ms
6,944 KB |
testcase_03 | AC | 359 ms
6,940 KB |
testcase_04 | AC | 351 ms
6,940 KB |
testcase_05 | AC | 317 ms
6,944 KB |
testcase_06 | AC | 281 ms
6,944 KB |
testcase_07 | AC | 262 ms
6,944 KB |
testcase_08 | AC | 260 ms
6,940 KB |
testcase_09 | AC | 412 ms
6,944 KB |
ソースコード
#include "bits/stdc++.h" using namespace std; typedef long long ll; typedef pair<int, int> pii; typedef pair<ll, ll> pll; const int INF = 1e9; const ll LINF = 1e18; template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; } template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; } template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; } template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; } /* <url:https://yukicoder.me/problems/no/173> 問題文============================================================ ================================================================= 解説============================================================= ================================================================ */ typedef long double ld; vector<int> get(vector<int> V,ld P){ vector<int> ret; size_t sz = V.size(); for(int i = 0; i < sz-1;i++){ int nowsz = (int)V.size(); ld p = rand()*1.0/RAND_MAX; int x = 0; if(p < P) x = 0; else x = 1 + (sz-1-i)*(p-P)/(1-P); ret.push_back(V[x]); V.erase(V.begin()+x); } ret.push_back(*V.begin()); return ret; } ld solve(){ srand((unsigned int)time(NULL)); ld res = 0; int N; cin >> N; ld Pa,Pb; cin >> Pa >> Pb; vector<int> A(N),B(N); for(auto& in:A) cin >> in; for(auto& in:B) cin >> in; sort(A.begin(),A.end()); sort(B.begin(),B.end()); ld win = 0; ld sum = 0; for(int kassa = 0; kassa < 200000; kassa++){ auto tA = get(A,Pa),tB = get(B,Pb); int score = 0; for(int i = 0; i < N;i++){ if(tA[i] > tB[i]) score += tA[i] + tB[i]; if(tA[i] < tB[i]) score -= tA[i] + tB[i]; } sum+=1; if(score>0)win+=1; } res = win/sum; return res; } int main(void) { cin.tie(0); ios_base::sync_with_stdio(false); cout << fixed << setprecision(12) << solve() << endl; return 0; }