結果
| 問題 |
No.173 カードゲーム(Medium)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-04-05 17:08:41 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 1,189 ms / 3,000 ms |
| コード長 | 1,760 bytes |
| コンパイル時間 | 778 ms |
| コンパイル使用メモリ | 96,084 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-07-04 02:07:11 |
| 合計ジャッジ時間 | 8,755 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 10 |
ソースコード
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;
unsigned xor128(){
static unsigned x=123456789,y=362436069,z=521288629,w=88675123;
unsigned t;
t=(x^(x<<11));x=y;y=z;z=w; return( w=(w^(w>>19))^(t^(t>>8)) );
}
int main()
{
int n;
double pa, pb;
cin >> n >> pa >> pb;
vector<int> a(n), b(n);
for(int i=0; i<n; ++i)
cin >> a[i];
for(int i=0; i<n; ++i)
cin >> b[i];
const int LOOP_TIME = 500000;
int win = 0;
for(int t=0; t<LOOP_TIME; ++t){
vector<int> x = a;
vector<int> y = b;
int score = 0;
for(int i=0; i<n; ++i){
sort(x.begin(), x.end() - i);
sort(y.begin(), y.end() - i);
if(i < n - 1){
if(xor128() / (double)UINT_MAX > pa){
int j = xor128() % (n - 1 - i) + 1;
swap(x[0], x[j]);
}
if(xor128() / (double)UINT_MAX > pb){
int j = xor128() % (n - 1 - i) + 1;
swap(y[0], y[j]);
}
}
if(x[0] > y[0])
score += x[0] + y[0];
else if(x[0] < y[0])
score -= x[0] + y[0];
swap(x[0], x[n-1-i]);
swap(y[0], y[n-1-i]);
}
if(score > 0)
++ win;
}
double ans = win / (double)LOOP_TIME;
printf("%.10f\n", ans);
return 0;
}