結果
| 問題 |
No.173 カードゲーム(Medium)
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-07-27 23:24:51 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,384 bytes |
| コンパイル時間 | 851 ms |
| コンパイル使用メモリ | 73,200 KB |
| 実行使用メモリ | 6,948 KB |
| 最終ジャッジ日時 | 2024-07-16 04:19:45 |
| 合計ジャッジ時間 | 2,715 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 6 WA * 4 |
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:47:10: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
47 | scanf("%d %lf %lf", &N, &PA, &PB);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:50:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
50 | scanf("%d", A+i);
| ~~~~~^~~~~~~~~~~
main.cpp:54:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
54 | scanf("%d", B+i);
| ~~~~~^~~~~~~~~~~
ソースコード
#include <cstdio>
#include <vector>
#include <random>
#include <algorithm>
const int T = 160000;
int N;
double PA, PB;
int A[20], B[20];
std::vector<int> va, vb;
std::random_device randomDevice;
std::mt19937 engine(randomDevice());
int simulate(int point_a, int point_b){
if(va.empty()){
return point_a > point_b;
}
int index, index2;
if(va.size() == 1 || engine() % 1000 < PA * 1000){
index = 0;
}else{
index = engine() % va.size();
}
if(vb.size() == 1 || engine() % 1000 < PB * 1000){
index2 = 0;
}else{
index2 = engine() % vb.size();
}
int point = va[index] + vb[index2];
if(va[index] > vb[index2]){
point_a += point;
}else if(va[index] < vb[index2]){
point_b += point;
}
va.erase(va.begin() + index);
vb.erase(vb.begin() + index2);
return simulate(point_a, point_b);
}
int main(){
scanf("%d %lf %lf", &N, &PA, &PB);
for(int i=0;i<N;i++){
scanf("%d", A+i);
}
for(int i=0;i<N;i++){
scanf("%d", B+i);
}
std::sort(A, A+N);
std::sort(B, B+N);
double res = 0.0;
for(int i=0;i<T;i++){
va.resize(N);
vb.resize(N);
std::copy(A, A+N, va.begin());
std::copy(B, B+N, vb.begin());
res += simulate(0, 0);
}
printf("%.6f\n", 1. * res / T);
}
tottoripaper