結果
| 問題 |
No.173 カードゲーム(Medium)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-08-17 20:29:46 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,571 bytes |
| コンパイル時間 | 1,227 ms |
| コンパイル使用メモリ | 165,636 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-18 10:02:41 |
| 合計ジャッジ時間 | 2,754 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 10 |
ソースコード
#include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); i++)
#define repr(i, a) for (int i = (a) - 1; i >= 0; i--)
#define repr2(i, a, b) for (int i = (b) - 1; i >= (a); i--)
using namespace std;
typedef long long ll;
const ll inf = 1e9;
const ll mod = 1e9 + 7;
struct XorShift {
unsigned z;
XorShift() : z((unsigned)time(NULL)) {}
XorShift(int seed) : z(z) {}
unsigned next() {
z ^= z << 13;
z ^= z >> 17;
z ^= z << 5;
return z;
}
unsigned nextInt(unsigned a, unsigned b) {
return next() % (b - a + 1) + a;
}
double nextDouble() {
return next() / (double)(1ll << 32);
}
};
bool usedA[10], usedB[10];
int main() {
int N;
double PA, PB;
cin >> N >> PA >> PB;
vector<int> A(N), B(N);
rep (i, N) cin >> A[i];
rep (i, N) cin >> B[i];
sort(A.begin(), A.end());
sort(B.begin(), B.end());
int winA = 0;
int winB = 0;
XorShift random;
const int C = 2e5;
rep (ii, C) {
int a = 0;
int b = 0;
vector<int> X(A), Y(B);
rep (i, N) {
int ia, ib;
if (i == N - 1 || random.nextDouble() <= PA) {
ia = 0;
} else {
ia = random.nextInt(1, X.size() - 1);
}
if (i == N - 1 || random.nextDouble() <= PB) {
ib = 0;
} else {
ib = random.nextInt(1, Y.size() - 1);
}
if (X[ia] > Y[ib]) {
a += X[ia] + Y[ib];
} else {
b += X[ia] + Y[ib];
}
X.erase(X.begin() + ia);
Y.erase(Y.begin() + ib);
}
if (a > b) winA++;
if (a < b) winB++;
}
cout << winA << endl;
double ans = (double)winA / C;
printf("%.20f\n", ans);
}